/*
 * echarts基于样式统一类
 *
 * line  折线图
 * lineD 面积图
 * lineZ 折线图带缩放
 * pie   饼状图
 * pieR  圆环
 * bar   柱状图
 * map   地图
 * sankey 桑基图
 * barMixPie  柱状，饼状图混搭
 * heatMap 热力图
 * */

var ECHART = {

    /**
     * 默认折线图
     */
    line: function (echart_data, item) {
        //是否带缩放控件
        var _dataZoom = [];
        //是否带单位
        var _axisLabel = {};
        //是否显示指标
        var _legend_show = true;
        //是否显示最大最小平均值
        var _series_mark = true;
        //Y轴单位
        var y_name = "";
        //接口返回的单位
        if (typeof echart_data.metric_unit != "undefined") {
            y_name = echart_data.metric_unit;
        }

        var _grid = {
            show: true,
            left: '4%',
            right: '10%',
            bottom: '5%',
            containLabel: true
        };

        //面积图
        var areaStyle = {};

        if (typeof(item) !== "undefined") {
            if (item.dataZoom) {
                _dataZoom = [
                    {
                        show: true,
                        startValue: 0,
                        endValue: item.dataZoom.endValue - 1,
                        handleSize: 10
                    },
                    {
                        type: 'inside',
                        startValue: 0,
                        zoomLock: true,
                        endValue: item.dataZoom.endValue - 1
                    }
                ];
            }
            if (item.axisLabel) {
                _axisLabel = {
                    formatter: '{value} ' + item.axisLabel.formatter
                }
            }

            if (item.grid) {
                _grid = item.grid;
            }
            if (item.y_name) {
                y_name = item.y_name;
            }

            if (typeof(item.series_mark) != "undefined") {
                _series_mark = item.series_mark;
            }

            if (typeof(item.legend) != "undefined" && typeof(item.legend.show) != "undefined") {
                _legend_show = item.legend.show;
            }
            //面积图
            if (typeof item.areaStyle != "undefined") {
                areaStyle = item.areaStyle;
            }
        }

        //调色盘颜色列表,依次使用
        var color = ['#e16c54', '#0095a5', '#a9f0f3', '#ee9835', '#43e3d6', '#eedb96', '#46647c', '#f395ae', '#5077b8', '#b4db82', '#dbae73'];

        var _series = [];

        for (var i = 0; i < echart_data.data.length; i++) {
            _series[i] = {};
            _series[i].name = echart_data.desc[i];
            _series[i].data = echart_data.data[i];
            _series[i].type = "line";
            _series[i].smooth = true;
            _series[i].areaStyle = areaStyle;

            if (_series_mark) {
                //最大值，最小值
                _series[i].markPoint = {};
                _series[i].markPoint.data = [];
                _series[i].markPoint.data[0] = {};
                _series[i].markPoint.data[0].type = "max";
                _series[i].markPoint.data[0].name = '最大值';
                _series[i].markPoint.data[1] = {};
                _series[i].markPoint.data[1].type = "min";
                _series[i].markPoint.data[1].name = '最小值';
                //平均线
                _series[i].markLine = {};
                _series[i].markLine.data = [];
                _series[i].markLine.data[0] = {};
                _series[i].markLine.data[0].type = "average";
                _series[i].markLine.data[0].name = '平均值';
            }
        }

        var formatter = null;
        if (item && item.formatter) {
            formatter = item.formatter;
        }
        var option = {
            //color:['#e16c54', '#0095a5', '#a9f0f3', '#ee9835', '#43e3d6', '#eedb96', '#46647c', '#f395ae', '#5077b8', '#b4db82', '#dbae73'],
            title: {
                text: '',
                show: false
            },
            tooltip: {
                trigger: 'axis',
                formatter: formatter
            },
            legend: {
                show: _legend_show,
                data: echart_data.desc
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        title: "下载"
                    }
                }
            },
            grid: _grid,
            xAxis: {
                type: 'category',
                boundaryGap: false,
                data: echart_data.spot
            },
            yAxis: {
                type: 'value',
                name: y_name,
                nameTextStyle: {
                    color: "#ACAAA4"
                },
                axisLabel: _axisLabel,
                scale: "true" == "true" ? true:false
            },
            dataZoom: _dataZoom,
            series: _series,
            stdExtend: {
                std_paramter: echart_data.std_paramter
            }
        };

        if(item && item.exportCsvFunc){
            option.toolbox.feature["myExportCsv"] = {
                show: true,
                title: '导出',
                icon: 'path://M249.856 389.12v-178.176c0-45.056 36.864-81.92 81.92-81.92h456.704l163.84 167.936v337.92c0 12.288-8.192 20.48-20.48 20.48s-20.48-8.192-20.48-20.48V337.92h-102.4c-34.816 0-61.44-26.624-61.44-61.44v-106.496h-415.744c-22.528 0-40.96 18.432-40.96 40.96v178.176h456.704c22.528 0 40.96 18.432 40.96 40.96v286.72c0 22.528-18.432 40.96-40.96 40.96h-456.704v61.44c0 22.528 18.432 40.96 40.96 40.96h538.624c22.528 0 40.96-18.432 40.96-40.96v-61.44c0-12.288 8.192-20.48 20.48-20.48s20.48 8.192 20.48 20.48v61.44c0 45.056-36.864 81.92-81.92 81.92h-538.624c-45.056 0-81.92-36.864-81.92-81.92v-61.44h-137.216c-22.528 0-40.96-18.432-40.96-40.96v-286.72c0-22.528 18.432-40.96 40.96-40.96h137.216z m538.624-202.752v90.112c0 10.24 8.192 20.48 20.48 20.48h86.016l-106.496-110.592z m-473.088 350.208c-14.336-38.912-40.96-57.344-83.968-59.392-59.392 4.096-90.112 36.864-94.208 102.4 2.048 65.536 34.816 100.352 94.208 102.4 47.104 0 77.824-22.528 88.064-67.584l-36.864-12.288c-4.096 32.768-22.528 47.104-49.152 47.104-34.816-2.048-53.248-26.624-55.296-71.68 2.048-45.056 20.48-67.584 55.296-69.632 24.576 2.048 40.96 14.336 47.104 36.864l34.816-8.192z m26.624 79.872c10.24 45.056 38.912 65.536 90.112 65.536s75.776-20.48 77.824-59.392c0-24.576-14.336-40.96-40.96-53.248l-36.864-12.288c-28.672-6.144-43.008-16.384-40.96-28.672 2.048-16.384 14.336-22.528 34.816-24.576 24.576 0 38.912 10.24 43.008 32.768l36.864-8.192c-6.144-36.864-34.816-57.344-81.92-55.296-45.056 2.048-69.632 20.48-71.68 53.248-2.048 28.672 16.384 47.104 57.344 57.344 10.24 2.048 20.48 4.096 30.72 8.192 22.528 6.144 32.768 16.384 30.72 30.72-2.048 18.432-14.336 26.624-38.912 28.672-28.672 0-47.104-14.336-51.2-45.056l-38.912 10.24z m380.928-137.216h-40.96l-49.152 145.408c-4.096 12.288-6.144 18.432-6.144 20.48 0-4.096-2.048-10.24-6.144-20.48l-51.2-147.456h-40.96l77.824 198.656h43.008l73.728-196.608z',
                onclick: function (){
                    item.exportCsvFunc(echart_data);
                }
            };
        }

        return option;
    },

    /**
     * 默认面积图
     */
    lineA: function (echart_data, item) {
        //是否带缩放控件
        var _dataZoom = [];
        //是否带单位
        var _axisLabel = {};
        //是否显示指标
        var _legend_show = true;
        //是否显示最大最小平均值
        var _series_mark = true;
        //提示框单位
        var _tooltip = '';
        //Y轴单位
        var y_name = "";
        //接口返回的单位
        if (typeof echart_data.metric_unit != "undefined") {
            y_name = echart_data.metric_unit;
        }

        var _grid = {
            show: true,
            left: '4%',
            right: '10%',
            bottom: '5%',
            containLabel: true
        };
        if (typeof(item) !== "undefined") {
            if (item.dataZoom) {
                _dataZoom = [
                    {
                        show: true,
                        startValue: 0,
                        endValue: item.dataZoom.endValue - 1,
                        handleSize: 10
                    },
                    {
                        type: 'inside',
                        startValue: 0,
                        zoomLock: true,
                        endValue: item.dataZoom.endValue - 1
                    }
                ];
            }
            if (item.axisLabel) {
                _axisLabel = {
                    formatter: '{value} ' + item.axisLabel.formatter
                }
            }
            if (item.tooltip && item.tooltip.formatter) {
                _tooltip = item.tooltip.formatter
            }

            if (item.grid) {
                _grid = item.grid;
            }

            if (typeof(item.series_mark) != "undefined") {
                _series_mark = item.series_mark;
            }

            if (typeof(item.legend) != "undefined" && typeof(item.legend.show) != "undefined") {
                _legend_show = item.legend.show;
            }
        }

        //调色盘颜色列表,依次使用
        var color = ['#e16c54', '#0095a5', '#a9f0f3', '#ee9835', '#43e3d6', '#eedb96', '#46647c', '#f395ae', '#5077b8', '#b4db82', '#dbae73'];

        var _series = [];

        for (var i = 0; i < echart_data.data.length; i++) {
            _series[i] = {};
            _series[i].name = echart_data.desc[i];
            _series[i].data = echart_data.data[i];
            _series[i].type = "line";
            _series[i].smooth = true;
            _series[i].areaStyle = {
                normal: {}
            };

            if (_series_mark) {
                //最大值，最小值
                _series[i].markPoint = {};
                _series[i].markPoint.data = [];
                _series[i].markPoint.data[0] = {};
                _series[i].markPoint.data[0].type = "max";
                _series[i].markPoint.data[0].name = '最大值';
                _series[i].markPoint.data[1] = {};
                _series[i].markPoint.data[1].type = "min";
                _series[i].markPoint.data[1].name = '最小值';
                //平均线
                _series[i].markLine = {};
                _series[i].markLine.data = [];
                _series[i].markLine.data[0] = {};
                _series[i].markLine.data[0].type = "average";
                _series[i].markLine.data[0].name = '平均值';
            }

        }

        var option = {

            title: {
                text: '',
                show: false
            },
            tooltip: {
                trigger: 'axis',
                formatter: _tooltip
            },
            legend: {
                show: _legend_show,
                data: echart_data.desc
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        title: "下载"
                    }
                }
            },
            grid: _grid,
            xAxis: {
                type: 'category',
                boundaryGap: false,
                data: echart_data.spot
            },
            yAxis: {
                type: 'value',
                name: y_name,
                nameTextStyle: {
                    color: "#ACAAA4"
                },
                axisLabel: _axisLabel
            },
            dataZoom: _dataZoom,
            series: _series,
            stdExtend: {
                std_paramter: echart_data.std_paramter
            }
        };

        return option;
    },

    /**
     * 默认折线堆叠图
     * */
    lineD: function (echart_data, item) {

        //调色盘颜色列表,依次使用
        var color = ['#e16c54', '#0095a5', '#a9f0f3', '#ee9835', '#43e3d6', '#eedb96', '#46647c', '#f395ae', '#5077b8', '#b4db82', '#dbae73'];

        var symbol = "emptyCircle";
        //是否带缩放控件
        var _dataZoom = [];
        //Y轴是否带单位
        var _axisLabel = {};
        //Y轴总单位
        var y_name = "";
        //接口返回的单位
        if (typeof echart_data.metric_unit != "undefined") {
            y_name = echart_data.metric_unit;
        }

        var _str = '';
        if (typeof(item) !== "undefined") {
            if (item.dataZoom) {
                _dataZoom = [
                    {
                        show: true,
                        startValue: 0,
                        endValue: item.dataZoom.endValue - 1,
                        handleSize: 10
                    },
                    {
                        type: 'inside',
                        startValue: 0,
                        zoomLock: true,
                        endValue: item.dataZoom.endValue - 1
                    }
                ];
            }
            if (item.axisLabel) {
                _axisLabel = {
                    formatter: '{value} ' + item.axisLabel.formatter
                };
                _str = item.axisLabel.formatter;
            }
            if (item.symbol) {
                symbol = item.symbol;
            }
            if (item.color) {
                color = item.color;
            }

        }
        var _series = [];

        for (var i = 0; i < echart_data.data.length; i++) {
            _series[i] = {};
            _series[i].name = echart_data.desc[i];
            _series[i].data = echart_data.data[i];
            _series[i].type = "line";
            _series[i].stack = '总量';
            _series[i].areaStyle = {};
            _series[i].areaStyle.normal = {};
            _series[i].smooth = true;
            _series[i].symbol = symbol;

            //最大值，最小值
            _series[i].markPoint = {};
            _series[i].markPoint.data = [];
            _series[i].markPoint.data[0] = {};
            _series[i].markPoint.data[0].type = "max";
            _series[i].markPoint.data[0].name = '最大值';
            _series[i].markPoint.data[1] = {};
            _series[i].markPoint.data[1].type = "min";
            _series[i].markPoint.data[1].name = '最小值';
            //平均线
            _series[i].markLine = {};
            _series[i].markLine.data = [];
            _series[i].markLine.data[0] = {};
            _series[i].markLine.data[0].type = "average";
            _series[i].markLine.data[0].name = '平均值';
        }

        var option = {

            title: {
                text: '',
                show: false
            },
            tooltip: {
                trigger: 'axis',
                formatter: function (params) {
                    var len = params.length;
                    if (typeof len != "undefined") {
                        var str = params[0].name + '<br />';
                        for (var i = 0; i < params.length; i++) {
                            str += params[i].seriesName + ' : ' + params[i].data + _str + '<br />';
                        }
                        return str;
                    } else {
                        var str2 = params.name + '<br />';
                        str2 += params.seriesName + ' : ' + params.value + _str + '<br />';
                        return str2;
                    }
                }
            },
            legend: {
                data: echart_data.desc
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        title: "下载"
                    }
                }
            },
            grid: {
                show: true,
                left: '4%',
                right: '10%',
                bottom: '5%',
                containLabel: true
            },
            xAxis: {
                type: 'category',
                boundaryGap: false,
                data: echart_data.spot
            },
            yAxis: {
                type: 'value',
                name: y_name,
                nameTextStyle: {
                    color: "#ACAAA4"
                },
                axisLabel: _axisLabel
            },
            dataZoom: _dataZoom,
            series: _series,
            stdExtend: {
                std_paramter: echart_data.std_paramter
            }
        };

        return option;
    },

    /**
     * 默认饼状图
     * */
    pie: function (echart_data, item) {

        var _spot = echart_data.spot;

        //调色盘颜色列表,依次使用
        var color = ['#e16c54', '#0095a5', '#a9f0f3', '#ee9835', '#43e3d6', '#eedb96', '#46647c', '#f395ae', '#5077b8', '#b4db82', '#dbae73'];
        var formatter = "{b} <br/>{a} : {c} ({d}%)";
        if (typeof(item) !== "undefined") {
            if (item.formatter) {
                formatter = item.formatter;
            }
        }

        var _data = echart_data.data[0] || ['0']; // 默认取第一组val数据
        var _desc = echart_data.desc[0] || [];

        var _series = {};
        _series.name = _desc;
        _series.data = [];
        for (var i = 0; i < _data.length; i++) {
            _series.data[i] = {};
            _series.data[i].name = _spot[i];
            _series.data[i].value = _data[i];
        }
        _series.type = "pie";
        _series.radius = "55%";
        _series.conter = ['50%', '60%'];
        _series.label = {
            emphasis: {
                show: true,
                textStyle: {
                    fontSize: '20',
                    fontWeight: 'bold'
                }
            }
        };

        var option = {
            title: {
                text: '',
                show: false
            },
            tooltip: {
                trigger: 'item',
                formatter: formatter
            },
            legend: {
                orient: 'vertical',
                left: 'left'
                //data: _spot
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        title: "下载"
                    }
                }
            },
            calculable: true,
            series: _series,
            stdExtend: {
                std_paramter: echart_data.std_paramter
            }
        };

        return option;
    },

    /**
     * 默认圆环
     * */
    pieR: function (echart_data, item) {
        var color = ['#e16c54', '#0095a5', '#a9f0f3', '#ee9835', '#43e3d6', '#eedb96', '#46647c', '#f395ae', '#5077b8', '#b4db82', '#dbae73'];

        var _series = [];
        var _length = echart_data.data.length;
        var _spot = echart_data.spot;
        var formatter = item && item.formatter || "{a} <br/>{b} : {c} ({d}%)";
        for (var i = 0; i < _length; i++) {
            _series[i] = {};
            _series[i].name = echart_data.desc[i];

            var _data = echart_data.data[i];
            _series[i].data = [];

            for (var j = 0; j < _data.length; j++) {
                _series[i].data[j] = {};
                _series[i].data[j].name = _spot[j];
                _series[i].data[j].value = _data[j];
            }
            _series[i].type = "pie";
        }
        if (_length == 1) {
            _series[0].radius = ['40%', '60%'];
        } else if (_length == 2) {
            _series[0].radius = ['0', '30%'];
            _series[1].radius = ['85', '65%'];
            _series[0].label = {
                normal: {
                    show: false,
                    position: 'center'
                },
                emphasis: {
                    show: true,
                    textStyle: {
                        fontSize: '30',
                        fontWeight: 'bold'
                    }
                }
            };
            _series[0].labelLine = {
                normal: {
                    show: false
                }
            }
        }

        var option = {
            title: {
                text: '',
                show: false
            },
            tooltip: {
                trigger: 'item',
                formatter: formatter
            },
            legend: {
                orient: 'vertical',
                left: 'left'
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        title: "下载"
                    }
                }
            },
            calculable: true,
            series: _series,
            stdExtend: {
                std_paramter: echart_data.std_paramter
            }
        };

        return option;
    },


    /**
     * 默认玫瑰图
     * */
    rose: function (echart_data, item) {

        var _spot = echart_data.spot;

        //调色盘颜色列表,依次使用
        var color = ['#e16c54', '#0095a5', '#a9f0f3', '#ee9835', '#43e3d6', '#eedb96', '#46647c', '#f395ae', '#5077b8', '#b4db82', '#dbae73'];

        var _data = echart_data.data[0] || ['0']; // 默认取第一组val数据
        var _desc = echart_data.desc[0] || [];

        var _series = {};
        _series.name = _desc;
        _series.data = [];

        var max = _data[0];
        var min = _data[_data.length - 1];
        for (var i = 0; i < _data.length; i++) {
            _series.data[i] = {};
            _series.data[i].name = _spot[i];
            _series.data[i].value = _data[i];
            _series.roseType = "radius";
        }
        _series.type = "pie";
        _series.radius = "55%";
        _series.roseType = "radius";
        _series.label = {
            normal: {
                textStyle: {
                    color: 'rgba(255, 0, 0,0.5)'
                }
            },
            emphasis: {
                show: true,
                textStyle: {
                    fontSize: '20',
                    fontWeight: 'bold'
                }
            }
        };
        _series.itemStyle = {
            normal: {
                color: '#c23531',
                shadowBlur: 200,
                shadowColor: 'rgba(0, 0, 0, 0.1)'
            }
        };
        _series.labelLine = {
            normal: {
                lineStyle: {
                    color: 'rgba(255, 0, 0, 0.5)'
                },
                smooth: 0.2,
                length: 10,
                length2: 20
            }
        };

        var option = {
            title: {
                text: '',
                show: false
            },
            tooltip: {
                trigger: 'item',
                formatter: "{b} <br/>{a} : {c} ({d}%)"
            },
            legend: {
                orient: 'vertical',
                left: 'left'
                //data: _spot
            },
            visualMap: {
                show: false,
                min: min - min / 10,
                max: max + max / 10,
                inRange: {
                    colorLightness: [0.3, 0.7]
                }
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        title: "下载"
                    }
                }
            },
            calculable: true,
            series: _series,
            stdExtend: {
                std_paramter: echart_data.std_paramter
            }
        };

        return option;
    },

    /**
     * 默认柱状图
     * */
    bar: function (echart_data, item) {

        var _dataZoom = [];
        var yAxis_axisLabel = {};
        var xAxis_axisLabel = {};
        var tooltip_fmt = false;
        //Y轴总单位
        var y_name = "";
        //接口返回的单位
        if (typeof echart_data.metric_unit != "undefined") {
            y_name = echart_data.metric_unit;
        }

        var spot = echart_data.spot;

        if (typeof(item) !== "undefined") {
            if (item.dataZoom) {
                _dataZoom = [
                    {
                        show: true,
                        startValue: 0,
                        endValue: item.dataZoom.endValue - 1,
                        handleSize: 10
                    },
                    {
                        type: 'inside',
                        startValue: 0,
                        zoomLock: true,
                        endValue: item.dataZoom.endValue - 1
                    }
                ];
            }
            if (item.y_name) {
                y_name = item.y_name;
            }
            if (item.axisLabel) {
                yAxis_axisLabel = {
                    formatter: '{value} ' + item.axisLabel.formatter
                }
            }
            if (item.xAxis_axisLabel) {
                xAxis_axisLabel = {
                    formatter: '{value} ' + item.xAxis_axisLabel.formatter
                }
            }
            if (item.tooltip && item.tooltip.formatter) {
                tooltip_fmt = "{b} <br/>{a} : {c}" + item.tooltip.formatter;
            }
        }
        //调色盘颜色列表,依次使用
        var color = ['#e16c54', '#0095a5', '#a9f0f3', '#ee9835', '#43e3d6', '#eedb96', '#46647c', '#f395ae', '#5077b8', '#b4db82', '#dbae73'];
        var _series = [];

        for (var i = 0; i < echart_data.data.length; i++) {

            _series[i] = {};
            _series[i].name = echart_data.desc[i];
            _series[i].data = echart_data.data[i];
            _series[i].type = "bar";
            _series[i].barMaxWidth = "40";
            _series[i].animationDelay = function (idx) {
                return idx * 10 + 100;
            };

            //最大值，最小值
            _series[i].markPoint = {};
            _series[i].markPoint.data = [];
            _series[i].markPoint.data[0] = {};
            _series[i].markPoint.data[0].type = "max";
            _series[i].markPoint.data[0].name = '最大值';
            _series[i].markPoint.data[1] = {};
            _series[i].markPoint.data[1].type = "min";
            _series[i].markPoint.data[1].name = '最小值';
            //平均线
            _series[i].markLine = {};
            _series[i].markLine.data = [];
            _series[i].markLine.data[0] = {};
            _series[i].markLine.data[0].type = "average";
            _series[i].markLine.data[0].name = '平均值';
        }

        var option = {
            title: {
                text: '',
                show: false
            },
            tooltip: {
                trigger: 'axis',
                formatter: tooltip_fmt,
                /* position: function(point,params,dom){
                 return [point[0],'30%'];
                 },*/
                axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            legend: {
                data: echart_data.desc
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        title: "下载"
                    }
                }
            },
            calculable: true,
            grid: {
                show: true,
                left: '4%',
                right: '10%',
                bottom: '8%',
                containLabel: true
            },
            xAxis: [
                {
                    type: 'category',
                    data: spot,
                    axisLabel: xAxis_axisLabel
                }
            ],
            yAxis: [
                {
                    type: 'value',
                    name: y_name,
                    nameTextStyle: {
                        color: "#ACAAA4"
                    },
                    axisLabel: yAxis_axisLabel
                }
            ],
            dataZoom: _dataZoom,
            series: _series,
            animationEasing: 'elasticOut',
            stdExtend: {
                std_paramter: echart_data.std_paramter
            }
        };

        if(item && item.exportCsvFunc){
            option.toolbox.feature["myExportCsv"] = {
                show: true,
                title: '导出',
                icon: 'path://M249.856 389.12v-178.176c0-45.056 36.864-81.92 81.92-81.92h456.704l163.84 167.936v337.92c0 12.288-8.192 20.48-20.48 20.48s-20.48-8.192-20.48-20.48V337.92h-102.4c-34.816 0-61.44-26.624-61.44-61.44v-106.496h-415.744c-22.528 0-40.96 18.432-40.96 40.96v178.176h456.704c22.528 0 40.96 18.432 40.96 40.96v286.72c0 22.528-18.432 40.96-40.96 40.96h-456.704v61.44c0 22.528 18.432 40.96 40.96 40.96h538.624c22.528 0 40.96-18.432 40.96-40.96v-61.44c0-12.288 8.192-20.48 20.48-20.48s20.48 8.192 20.48 20.48v61.44c0 45.056-36.864 81.92-81.92 81.92h-538.624c-45.056 0-81.92-36.864-81.92-81.92v-61.44h-137.216c-22.528 0-40.96-18.432-40.96-40.96v-286.72c0-22.528 18.432-40.96 40.96-40.96h137.216z m538.624-202.752v90.112c0 10.24 8.192 20.48 20.48 20.48h86.016l-106.496-110.592z m-473.088 350.208c-14.336-38.912-40.96-57.344-83.968-59.392-59.392 4.096-90.112 36.864-94.208 102.4 2.048 65.536 34.816 100.352 94.208 102.4 47.104 0 77.824-22.528 88.064-67.584l-36.864-12.288c-4.096 32.768-22.528 47.104-49.152 47.104-34.816-2.048-53.248-26.624-55.296-71.68 2.048-45.056 20.48-67.584 55.296-69.632 24.576 2.048 40.96 14.336 47.104 36.864l34.816-8.192z m26.624 79.872c10.24 45.056 38.912 65.536 90.112 65.536s75.776-20.48 77.824-59.392c0-24.576-14.336-40.96-40.96-53.248l-36.864-12.288c-28.672-6.144-43.008-16.384-40.96-28.672 2.048-16.384 14.336-22.528 34.816-24.576 24.576 0 38.912 10.24 43.008 32.768l36.864-8.192c-6.144-36.864-34.816-57.344-81.92-55.296-45.056 2.048-69.632 20.48-71.68 53.248-2.048 28.672 16.384 47.104 57.344 57.344 10.24 2.048 20.48 4.096 30.72 8.192 22.528 6.144 32.768 16.384 30.72 30.72-2.048 18.432-14.336 26.624-38.912 28.672-28.672 0-47.104-14.336-51.2-45.056l-38.912 10.24z m380.928-137.216h-40.96l-49.152 145.408c-4.096 12.288-6.144 18.432-6.144 20.48 0-4.096-2.048-10.24-6.144-20.48l-51.2-147.456h-40.96l77.824 198.656h43.008l73.728-196.608z',
                onclick: function (){
                    item.exportCsvFunc(echart_data);
                }
            };
        }

        return option;
    },


    /**
     * 水平柱状图
     * */
    barH: function (echart_data, item) {

        var _dataZoom = [];
        var yAxis_axisLabel = {};
        var xAxis_axisLabel = {};
        var tooltip_fmt = false;
        //X轴总单位
        var x_name = "";
        //接口返回的单位
        if (typeof echart_data.metric_unit != "undefined") {
            x_name = echart_data.metric_unit;
        }

        var spot = echart_data.spot;

        if (typeof(item) !== "undefined") {
            if (item.dataZoom) {
                _dataZoom = [
                    {
                        show: true,
                        startValue: 0,
                        endValue: item.dataZoom.endValue - 1,
                        handleSize: 10
                    },
                    {
                        type: 'inside',
                        startValue: 0,
                        zoomLock: true,
                        endValue: item.dataZoom.endValue - 1
                    }
                ];
            }
            if (item.axisLabel) {
                yAxis_axisLabel = {
                    formatter: '{value} ' + item.axisLabel.formatter
                }
            }
            if (item.xAxis_axisLabel) {
                xAxis_axisLabel = {
                    formatter: '{value} ' + item.xAxis_axisLabel.formatter
                }
            }
            if (item.tooltip && item.tooltip.formatter) {
                tooltip_fmt = "{b} <br/>{a} : {c}" + item.tooltip.formatter;
            }
        }
        //调色盘颜色列表,依次使用
        var color = ['#e16c54', '#0095a5', '#a9f0f3', '#ee9835', '#43e3d6', '#eedb96', '#46647c', '#f395ae', '#5077b8', '#b4db82', '#dbae73'];
        var _series = [];

        for (var i = 0; i < echart_data.data.length; i++) {
            _series[i] = {};
            _series[i].name = echart_data.desc[i];
            _series[i].data = echart_data.data[i];
            _series[i].type = "bar";
            _series[i].barMaxWidth = "40";
            _series[i].animationDelay = function (idx) {
                return idx * 10 + 100;
            };


        }

        var option = {
            title: {
                text: '',
                show: false
            },
            tooltip: {
                trigger: 'axis',
                formatter: tooltip_fmt,
                /* position: function(point,params,dom){
                 return [point[0],'30%'];
                 },*/
                axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            legend: {
                data: echart_data.desc
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        title: "下载"
                    }
                }
            },
            calculable: true,
            grid: {
                show: true,
                left: '4%',
                right: '10%',
                bottom: '5%',
                containLabel: true
            },
            xAxis: [
                {
                    type: 'value',
                    name: x_name,
                    nameTextStyle: {
                        color: "#ACAAA4"
                    },
                    axisLabel: yAxis_axisLabel
                }
            ],
            yAxis: [
                {
                    type: 'category',
                    data: spot,
                    axisLabel: xAxis_axisLabel
                }
            ],
            dataZoom: _dataZoom,
            series: _series,
            animationEasing: 'elasticOut',
            stdExtend: {
                std_paramter: echart_data.std_paramter
            }
        };

        if(item && item.exportCsvFunc){
            option.toolbox.feature["myExportCsv"] = {
                show: true,
                title: '导出',
                icon: 'path://M249.856 389.12v-178.176c0-45.056 36.864-81.92 81.92-81.92h456.704l163.84 167.936v337.92c0 12.288-8.192 20.48-20.48 20.48s-20.48-8.192-20.48-20.48V337.92h-102.4c-34.816 0-61.44-26.624-61.44-61.44v-106.496h-415.744c-22.528 0-40.96 18.432-40.96 40.96v178.176h456.704c22.528 0 40.96 18.432 40.96 40.96v286.72c0 22.528-18.432 40.96-40.96 40.96h-456.704v61.44c0 22.528 18.432 40.96 40.96 40.96h538.624c22.528 0 40.96-18.432 40.96-40.96v-61.44c0-12.288 8.192-20.48 20.48-20.48s20.48 8.192 20.48 20.48v61.44c0 45.056-36.864 81.92-81.92 81.92h-538.624c-45.056 0-81.92-36.864-81.92-81.92v-61.44h-137.216c-22.528 0-40.96-18.432-40.96-40.96v-286.72c0-22.528 18.432-40.96 40.96-40.96h137.216z m538.624-202.752v90.112c0 10.24 8.192 20.48 20.48 20.48h86.016l-106.496-110.592z m-473.088 350.208c-14.336-38.912-40.96-57.344-83.968-59.392-59.392 4.096-90.112 36.864-94.208 102.4 2.048 65.536 34.816 100.352 94.208 102.4 47.104 0 77.824-22.528 88.064-67.584l-36.864-12.288c-4.096 32.768-22.528 47.104-49.152 47.104-34.816-2.048-53.248-26.624-55.296-71.68 2.048-45.056 20.48-67.584 55.296-69.632 24.576 2.048 40.96 14.336 47.104 36.864l34.816-8.192z m26.624 79.872c10.24 45.056 38.912 65.536 90.112 65.536s75.776-20.48 77.824-59.392c0-24.576-14.336-40.96-40.96-53.248l-36.864-12.288c-28.672-6.144-43.008-16.384-40.96-28.672 2.048-16.384 14.336-22.528 34.816-24.576 24.576 0 38.912 10.24 43.008 32.768l36.864-8.192c-6.144-36.864-34.816-57.344-81.92-55.296-45.056 2.048-69.632 20.48-71.68 53.248-2.048 28.672 16.384 47.104 57.344 57.344 10.24 2.048 20.48 4.096 30.72 8.192 22.528 6.144 32.768 16.384 30.72 30.72-2.048 18.432-14.336 26.624-38.912 28.672-28.672 0-47.104-14.336-51.2-45.056l-38.912 10.24z m380.928-137.216h-40.96l-49.152 145.408c-4.096 12.288-6.144 18.432-6.144 20.48 0-4.096-2.048-10.24-6.144-20.48l-51.2-147.456h-40.96l77.824 198.656h43.008l73.728-196.608z',
                onclick: function (){
                    item.exportCsvFunc(echart_data);
                }
            };
        }

        return option;
    },

    /**
     * 水平堆叠图
     * */
    barHS: function (echart_data, item) {

        var _dataZoom = [];
        var yAxis_axisLabel = {};
        var xAxis_axisLabel = {};
        var tooltip_fmt = false;
        //X轴总单位
        var x_name = "";
        //接口返回的单位
        if (typeof echart_data.metric_unit != "undefined") {
            x_name = echart_data.metric_unit;
        }

        var spot = echart_data.spot;

        if (typeof(item) !== "undefined") {
            if (item.dataZoom) {
                _dataZoom = [
                    {
                        show: true,
                        startValue: 0,
                        endValue: item.dataZoom.endValue - 1,
                        handleSize: 10
                    },
                    {
                        type: 'inside',
                        startValue: 0,
                        zoomLock: true,
                        endValue: item.dataZoom.endValue - 1
                    }
                ];
            }
            if (item.axisLabel) {
                yAxis_axisLabel = {
                    formatter: '{value} ' + item.axisLabel.formatter
                }
            }
            if (item.xAxis_axisLabel) {
                xAxis_axisLabel = {
                    formatter: '{value} ' + item.xAxis_axisLabel.formatter
                }
            }
            if (item.tooltip && item.tooltip.formatter) {
                tooltip_fmt = "{b} <br/>{a} : {c}" + item.tooltip.formatter;
            }
        }
        //调色盘颜色列表,依次使用
        var color = ['#e16c54', '#0095a5', '#a9f0f3', '#ee9835', '#43e3d6', '#eedb96', '#46647c', '#f395ae', '#5077b8', '#b4db82', '#dbae73'];
        var _series = [];

        for (var i = 0; i < echart_data.data.length; i++) {
            _series[i] = {};
            _series[i].name = echart_data.desc[i];
            _series[i].data = echart_data.data[i];
            _series[i].type = "bar";
            _series[i].stack = '总量';
            _series[i].barMaxWidth = "40";
            _series[i].animationDelay = function (idx) {
                return idx * 10 + 100;
            };
        }

        var option = {
            title: {
                text: '',
                show: false
            },
            tooltip: {
                trigger: 'axis',
                formatter: tooltip_fmt,
                axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            legend: {
                data: echart_data.desc
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        title: "下载"
                    }
                }
            },
            calculable: true,
            grid: {
                show: true,
                left: '4%',
                right: '10%',
                bottom: '5%',
                containLabel: true
            },
            xAxis: [
                {
                    type: 'value',
                    name: x_name,
                    axisLabel: yAxis_axisLabel
                }
            ],
            yAxis: [
                {
                    type: 'category',
                    data: spot,
                    axisLabel: xAxis_axisLabel
                }
            ],
            dataZoom: _dataZoom,
            series: _series,
            animationEasing: 'elasticOut',
            stdExtend: {
                std_paramter: echart_data.std_paramter
            }
        };

        return option;
    },


    /**
     * 组成柱状图
     * */
    barZ: function (echart_data, item) {

        var _dataZoom = [];
        var yAxis_axisLabel = {};
        var xAxis_axisLabel = {};
        if (typeof(item) !== "undefined") {
            if (item.dataZoom) {
                _dataZoom = [
                    {
                        show: true,
                        startValue: 0,
                        endValue: item.dataZoom.endValue - 1,
                        handleSize: 10
                    },
                    {
                        type: 'inside',
                        startValue: 0,
                        zoomLock: true,
                        endValue: item.dataZoom.endValue - 1
                    }
                ];
            }
            if (item.axisLabel) {
                yAxis_axisLabel = {
                    formatter: '{value} ' + item.axisLabel.formatter
                }
            }
            if (item.xAxis_axisLabel) {
                xAxis_axisLabel = {
                    formatter: '{value} ' + item.xAxis_axisLabel.formatter
                }
            }
        }
        //调色盘颜色列表,依次使用
        var color = ['#e16c54', '#0095a5', '#a9f0f3', '#ee9835', '#43e3d6', '#eedb96', '#46647c', '#f395ae', '#5077b8', '#b4db82', '#dbae73'];
        var _series = [];

        for (var i = 0; i < echart_data.data.length; i++) {
            _series[i] = {};
            _series[i].name = echart_data.desc[i];
            _series[i].data = echart_data.data[i];
            _series[i].stack = "总量";
            _series[i].type = "bar";
            _series[i].barMaxWidth = "40";
            _series[i].animationDelay = function (idx) {
                return idx * 10 + 100;
            };

            if (i === 0) {
                //如果是第一组辅助数据，做特殊处理
                _series[i].itemStyle = {};
                _series[i].itemStyle.normal = {};
                _series[i].itemStyle.normal.barBorderColor = "rgba(0,0,0,0)";
                _series[i].itemStyle.normal.color = "rgba(0,0,0,0)";
                _series[i].itemStyle.emphasis = {};
                _series[i].itemStyle.emphasis.barBorderColor = "rgba(0,0,0,0)";
                _series[i].itemStyle.emphasis.color = "rgba(0,0,0,0)";
            } else {
                _series[i].label = {};
                _series[i].label.normal = {};
                _series[i].label.normal.show = true;
                _series[i].label.normal.position = "inside";
            }
        }

        var option = {
            title: {
                text: '',
                show: false
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                },
                formatter: function (params) {
                    var tar = params[1];
                    return tar.name + ' : ' + tar.value;
                }
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        title: "下载"
                    }
                }
            },
            calculable: true,
            grid: {
                show: true,
                left: '4%',
                right: '10%',
                bottom: '5%',
                containLabel: true
            },
            xAxis: [
                {
                    type: 'category',
                    splitLine: {show: false},
                    data: echart_data.spot
                }
            ],
            yAxis: [
                {
                    type: 'value'
                }
            ],
            dataZoom: _dataZoom,
            series: _series,
            animationEasing: 'elasticOut',
            stdExtend: {
                std_paramter: echart_data.std_paramter
            }
        };

        return option;
    },

    /**
     * 默认柱状堆叠图
     * */
    barS: function (echart_data, item) {

        var xAxis_axisLabel = {};
        if (typeof(item) !== "undefined") {
            if (item.xAxis_axisLabel) {
                xAxis_axisLabel = {
                    formatter: '{value} ' + item.xAxis_axisLabel.formatter
                }
            }
        }
        //调色盘颜色列表,依次使用
        var color = ['#e16c54', '#0095a5', '#a9f0f3', '#ee9835', '#43e3d6', '#eedb96', '#46647c', '#f395ae', '#5077b8', '#b4db82', '#dbae73'];
        var _series = [];

        for (var i = 0; i < echart_data.data.length; i++) {
            _series[i] = {};
            _series[i].name = echart_data.desc[i];
            _series[i].data = echart_data.data[i];
            _series[i].type = "bar";
            _series[i].stack = '总量';
            _series[i].barMaxWidth = "40";
        }
        var option = {
            title: {
                text: '',
                show: false
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        title: "下载"
                    }
                }
            },
            legend: {
                data: echart_data.desc
            },
            grid: {
                show: true,
                left: '4%',
                right: '10%',
                bottom: '5%',
                containLabel: true
            },
            xAxis: [
                {
                    type: 'category',
                    data: echart_data.spot,
                    axisLabel: xAxis_axisLabel
                }
            ],
            yAxis: [
                {
                    type: 'value'
                }
            ],
            series: _series,
            stdExtend: {
                std_paramter: echart_data.std_paramter
            }
        };
        return option;
    },

    /**
     * 默认地图
     * */
    map: function (echart_data, map, item) {
        var legend_show = true;
        //Y轴单位
        var y_name = "";
        //接口返回的单位
        if (typeof echart_data.metric_unit != "undefined") {
            y_name = echart_data.metric_unit;
        }
        if (typeof item != "undefined") {
            if (typeof item.legend_show != "undefined") {
                legend_show = item.legend_show;
            }
        }
        if($.isEmptyObject(map)){
            map=publicData.Area.getMap();
        }

        echarts.registerMap(map.geoName, JSON.parse(map.geoJson));

        var _series = [];
        var _max = 100;
        var option = {};
        echart_data.desc = echart_data.desc || [];

        for (var i = 0; i < echart_data.desc.length; i++) {
            _series[i] = {};
            _series[i].name = echart_data.desc[i];
            _series[i].type = "map";
            _series[i].mapType = map.geoName;
            _series[i].label = {};
            _series[i].label.emphasis = {};
            _series[i].label.emphasis.show = true;

            _series[i].data = [];
            var _data = echart_data.data[i] || [];
            var spot_name = echart_data.spot;

            for (var j = 0; j < _data.length; j++) {
                _series[i].data[j] = {};
                _series[i].data[j].name = spot_name[j];
                _series[i].data[j].value = _data[j];
                if (_max < _data[j]) {
                    _max = Math.ceil(_data[j]);
                }
            }
            var _mm = _max % 100;
            if (_mm > 0) {
                _max = (_max - _mm) + 100;
            }
        }

        option = {
            title: {
                text: '',
                show: false
            },
            tooltip: {
                trigger: 'item',
                formatter: function (params) {
                    //只适用于单个指标
                    var a = params.seriesName;
                    var b = params.name;
                    var c = params.value;
                    if (isNaN(c)) {
                        return a + '<br/>' + b + '：-'
                    } else {
                        return a + '<br/>' + b + '：' + c + ' ' + y_name;
                    }
                }
            },
            legend: {
                show: legend_show,
                orient: 'vertical',
                left: 'left',
                data: echart_data.desc
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        title: "下载"
                    }
                }
            },
            visualMap: {
                min: 0,
                max: _max,
                left: 'left',
                top: 'bottom',
                // 文本，默认为数值文本
                text: ['高', '低'],
                calculable: true
            },
            series: _series,
            stdExtend: {
                std_paramter: echart_data.std_paramter
            }
        };

        return option;
    },

    /*
     * 桑基图
     * */
    sankey: function (echart_data, item) {

        var option = {
            title: {
                text: '',
                show: false
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        title: "下载"
                    }
                }
            },
            tooltip: {
                trigger: 'item',
                triggerOn: 'mousemove',
                formatter: function (params) {
                    if (typeof params.data.source != "undefined" && typeof params.data.target != "undefined" && typeof params.data.value != "undefined") {
                        return params.data.source + " -- " + params.data.target + " 转换率：" + params.data.value + "%";
                    } else {
                        return params.data.id;
                    }

                }

            },
            series: [
                {
                    type: 'sankey',
                    layout: 'none',
                    data: echart_data.nodes,
                    links: echart_data.links,
                    itemStyle: {
                        normal: {
                            borderWidth: 1,
                            borderColor: '#aaa'
                        }
                    },
                    lineStyle: {
                        normal: {
                            color: 'source',
                            curveness: 0.5
                        }
                    }
                }
            ],
            stdExtend: {
                std_paramter: echart_data.std_paramter
            }
        };

        return option;
    },

    /*
     * 散点图
     **/

    scatter: function (echart_data, item) {
        var _series = [];
        for (var i = 0; i < echart_data.data[0].length; i++) {
            var Range = 100 - 0;
            var Rand = Math.random();
            var Abscissa = 0 + Math.round(Rand * Range); //四舍五入
            var scatterVal = Object.create(null);
            scatterVal = {
                symbolSize: echart_data.data[0][i],
                //symbolSize:Abscissa,
                name: echart_data.desc[0],
                type: "scatter",
                label: {
                    emphasis: {
                        show: true,
                        formatter: function (param) {
                            return param.data[3];
                        },
                        position: 'top'
                    }
                },
                itemStyle: {
                    normal: {
                        shadowBlur: 10,
                        shadowColor: 'rgba(120, 36, 50, 0.5)',
                        shadowOffsetY: 5,
                        color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{
                            offset: 0,
                            color: 'rgb(251, 118, 123)'
                        }, {
                            offset: 1,
                            color: 'rgb(204, 46, 72)'
                        }])
                    }
                }
            };
            scatterVal.data = [];
            scatterVal.data.push([Abscissa, parseInt(echart_data.data[0][i])]);
            //scatterVal.data.push([Abscissa,Abscissa+Abscissa]);
            _series.push(scatterVal);
        }
        ;
        var option = {
            title: {
                text: '',
                show: false
            },
            legend: {
                //right: 50,
                data: [echart_data.desc[0]]
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        title: "下载"
                    }
                }
            },
            xAxis: {
                splitLine: {
                    lineStyle: {
                        type: 'dashed'
                    }
                }
            },
            yAxis: {
                splitLine: {
                    lineStyle: {
                        type: 'dashed'
                    }
                },
                scale: true
            },
            series: _series
        };
        return option;
    },


    /**
     * 柱状图，饼状图混搭
     * */
    barMixPie: function (echart_data, item) {

        var option = {
            title: {
                text: '',
                show: false
            },
            tooltip: {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c}%"
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        title: "下载"
                    }
                }
            },
            calculable: true,
            xAxis: [
                {
                    type: 'category',
                    data: echart_data.spot
                }
            ],
            yAxis: [
                {
                    max: 100,
                    type: 'value'
                }
            ],
            series: [
                {
                    name: echart_data.desc[0],
                    type: 'bar',
                    barMaxWidth: "50",
                    itemStyle: {
                        normal: {
                            color: function (params) {
                                var colorList = [
                                    '#C1232B', '#B5C334', '#FCCE10', '#E87C25', '#27727B',
                                    '#FE8463', '#9BCA63', '#FAD860', '#F3A43B', '#60C0DD',
                                    '#D7504B', '#C6E579', '#F4E001', '#F0805A', '#26C0C0'
                                ];
                                return colorList[params.dataIndex]
                            }
                        }
                    },
                    data: echart_data.data[0],
                    markPoint: {
                        data: [
                            {type: 'max', name: '最大值'},
                            {type: 'min', name: '最小值'}
                        ]
                    }//,
//                    markLine: {
//                        lineStyle: {
//                            normal: {
//                                color: "#F0805A"
//                            }
//                        },
//                        data: [
//                            {type: 'average', name: '//', color: 'D7504B'}
//                        ]
//                    }
                }
                ,
                {
                    center: ['83%', '30%'],
                    radius: '38%',
                    name: '观影转换率',
                    type: 'pie',
                    data: []
                }
            ],
            stdExtend: {
                std_paramter: echart_data.std_paramter
            }
        };
        return option;
    },


    /**
     * 雷达图
     * */
    radar: function (echart_data, item) {

        var spot = echart_data.spot;
        var indicator = [];

        //调色盘颜色列表,依次使用
        var color = ['#e16c54', '#0095a5', '#a9f0f3', '#ee9835', '#43e3d6', '#eedb96', '#46647c', '#f395ae', '#5077b8', '#b4db82', '#dbae73'];
        var _data = [];

        for (var i = 0; i < echart_data.data.length; i++) {
            _data[i] = {};
            _data[i].value = echart_data.data[i];
            _data[i].name = echart_data.desc[i];
        }

        for (var j = 0; j < spot.length; j++) {
            indicator.push({
                text: spot[j],
                max: 100
            });
        }
        var option = {
            title: {
                text: '',
                show: false
            },
            tooltip: {
                trigger: 'axis'
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        title: "下载"
                    }
                }
            },
            legend: {
                data: echart_data.desc,
                x: 'left'
            },
            radar: [
                {
                    indicator: indicator,
                    center: ['50%', '50%'],
                    radius: 120
                }
            ],
            series: [
                {
                    type: 'radar',
                    tooltip: {
                        trigger: 'item'
                    },
                    itemStyle: {normal: {areaStyle: {type: 'default'}}},
                    /*itemStyle: {
                     emphasis: {
                     lineStyle: {
                     width: 4
                     }
                     }
                     },*/
                    data: _data
                }
            ],
            stdExtend: {
                std_paramter: echart_data.std_paramter
            }

        };

        return option;
    },


    /**
     * 矩形树图
     * */
    treeMap: function (echart_data, item) {

        var option = {};
        var color = ['#e16c54', '#0095a5', '#a9f0f3', '#ee9835', '#43e3d6', '#eedb96', '#46647c', '#f395ae', '#5077b8', '#b4db82', '#dbae73'];
        var map_data = [];

        for (var i = 0; i < echart_data.desc.length; i++) {
            var _data = echart_data.data[i] || [];
            var spot_name = echart_data.spot;
            var series_name = echart_data.desc[i];
            for (var j = 0; j < _data.length; j++) {
                map_data[j] = {};
                map_data[j].name = spot_name[j];
                map_data[j].value = _data[j];
            }
        }

        option = {
            title: {
                text: '',
                show: false
            },
            tooltip: {
                formatter: '{b}<br>{a}: {c}'
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        title: "下载"
                    }
                }
            },
            series: [{
                name: series_name,
                type: 'treemap',
                label: {
                    show: true,
                    formatter: "{b}",
                    normal: {
                        textStyle: {
                            ellipsis: true,
                            color: '#fff'
                        }
                    }
                },
                itemStyle: {
                    normal: {
                        borderColor: 'rgba(0,0,0,0)',
                        borderWidth: 1
                    }
                },
                breadcrumb: {
                    show: false
                },
                data: map_data
            }],
            stdExtend: {
                std_paramter: echart_data.std_paramter
            }
        };

        return option;
    },


    /**
     * 仪表盘
     * */
    gauge: function (echart_data, item) {
        var _max = 100;
        if (typeof item != "undefined") {
            if (typeof item.max != "undefined" && item.max != "") {
                _max = item.max;
            }
        }

        var option = {};
        var _series = [];
        var _length = echart_data.data.length;
        var _temp = 100 / (_length + 1);
        for (var i = 0; i < _length; i++) {
            _series[i] = {};
            _series[i].type = "gauge";
            _series[i].data = {};
            _series[i].data.value = 0;
            _series[i].max = _max;
            //获取最后一个有数据的点

            var data = echart_data.data[i];
            for (var j = 0; j < data.length; j++) {
                if (!isNaN(data[j]) && data[j] > 0) {
                    _series[i].data.value = data[j];
                }
            }
            //_series[i].data.name = echart_data.desc[i];
            _series[i].center = [_temp * (i + 1) + "%", "50%"];
        }

        option = {
            title: {
                text: '',
                show: false
            },
            toolbox: {
                feature: {
                    saveAsImage: {
                        title: "下载"
                    }
                }
            },
            axisLabel: {
                formatter: function (value) {
                    return Math.round(value);
                }
            },
            series: _series,
            stdExtend: {
                std_paramter: echart_data.std_paramter
            }
        };

        return option;
    },

    /**
     * 热力图
     */
    heatMap: function (echart_data, item) {

        if(!echart_data) {
            return;
        }

        var item = item || {};

        var color = ['#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf', '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026'];
        var option = {
            tooltip: {
                show: true,
                formatter: function(param){
                    return (item.tooltip_name || '指标参数') + ': ' +  (param.data[2] || param.data.value[2]);
                }
            },
            grid: {
                width: '100%',
                height: '100%',
                bottom: 0,
                left: 0,
                backgroundColor: '#e6e6e6',
                show: true
            },
            animation: false,
            visualMap: {
                min: echart_data.min || 0,
                max: echart_data.max || 1,
                calculable: true,
                inRange: {
                    color: item.color || color
                },
                show: false
            },
            graphic: [{
                type: 'image',
                id: 'bg_image',
                left: 0,
                bottom: 0,
                z: -10
            }],
            xAxis: {
                type: 'category',
                data: echart_data.xData || [],
                splitLine: {
                    show: false
                }
            },
            yAxis: {
                type: 'category',
                data: echart_data.yData || [],
                splitLine: {
                    show: false
                }
            },
            series: [{
                name: item.tooltip_name || '指标参数',
                type: 'heatmap',
                data: echart_data.points,
                itemStyle: {
                    emphasis: {
                        shadowBlur: 10,
                        shadowColor: 'rgba(0, 0, 0, 0.5)',
                        borderWidth: 1,
                        borderColor: '#333'
                    }
                },
                progressive: 1000,
                animation: false
            }]
        };

        return option;
    }
};

var EcHandle = {

    /**
     * 为了适应echart在不同场景下应用
     * 这里做蛋疼的特殊处理
     * */


    /**
     * 柱状图-组成图
     * 接口是按照天粒度返回数据
     * @_cfg 配置参数，JSON格式
     * */
    constituteBar: function (_obj, _cfg) {
        var _item = [];
        var _count = 0;
        //计算第二组数据 start
        for (var i = 0; i < _obj.data.length; i++) {
            var _data = _obj.data[i];
            var _val = 0;
            for (_idx in _data) {
                if (isNaN(parseInt(_data[_idx]))) {
                    continue;
                }
                //由于接口返回是按照天粒度返回数据
                //这里把相同指标的所以粒度相加求和
                _val += Math.round(_data[_idx]);
            }
            _count += _val;
            _item.push(_val);
        }
        _item.unshift(_count); //把总数插到数组第一位

        _obj.data = [];//清空数组原有元素
        _obj.data.push(_item);
        //计算第二组数据 end

        //计算第一组辅助数据 start
        var _new_item = [];
        for (var i = 1; i < _item.length; i++) {//由于第一位是总数，这里跳过数组中第一位
            _count -= _item[i];//用总数减去已结算组成部分
            _new_item.push(_count);
        }
        _new_item.unshift(0);//辅助数据，第一位总是为0
        _obj.data.unshift(_new_item);
        //计算第一组辅助数据 end

        _obj.spot = _obj.desc; //指标名称调换到维度使用
        _obj.spot.unshift(_cfg.firstDim);//由于第一列总数为前端计算，接口未下发名称，所以需要调用接口传入参数

        return _obj;
    },

    /**
     * 柱状图，饼状图混搭数据调用
     * 柱状图数据处理
     * */
    barMixPieByBar: function (echart_data, depth) {
        var bar_data = [];
        bar_data.data = echart_data.data.splice(1, 1);
        bar_data.desc = echart_data.desc.splice(1, 1);
        var _spot = echart_data.spot;
        bar_data.spot = [];
        var _dp = depth.split(',');
        for (var h = 0; h < _spot.length; h++) {
            for (var i = 0; i < _dp.length; i++) {
                var _arr_dp = _dp[i].split("|");
                var _idx = _arr_dp[2];//取最后一位顺序
                _arr_dp[1] = parseInt(_arr_dp[1]) - 1;
                if (_idx != _spot[h]) {
                    continue;
                }
                var _name = "";
                if (_arr_dp[0] != _arr_dp[1]) {
                    _name = _arr_dp[0].toString() + "-" + _arr_dp[1] + "页";
                } else {
                    _name = _arr_dp[0] + "页";
                }
                bar_data.spot.push(_name);
                break;
            }
        }
        bar_data.spot.push("其它");
        return bar_data;
    },

    /**
     * 柱状图，饼状图混搭数据调用
     * 饼状图数据处理
     * */
    barMixPieByPie: function (echart_data, depth, key) {
        var bar_data = [];
        var _spot = echart_data.spot;
        bar_data.spot = [];
        var _dp = depth.split(',');
        for (var h = 0; h < _spot.length; h++) {
            for (var i = 0; i < _dp.length; i++) {
                var _arr_dp = _dp[i].split("|");
                var _idx = _arr_dp[2];//取最后一位顺序
                _arr_dp[1] = parseInt(_arr_dp[1]) - 1;
                if (_idx != _spot[h]) {
                    continue;
                }
                var _name = "";
                if (_arr_dp[0] != _arr_dp[1]) {
                    _name = _arr_dp[0].toString() + "-" + _arr_dp[1] + "页";
                } else {
                    _name = _arr_dp[0] + "页";
                }
                if (_name == key) {
                    return Math.round(echart_data.data[0][h]);

                }
                break;
            }
        }
        return 0;
    }

};


var STD = {

    /**
     * UI相关
     * */
    UI: {

        /*
         * 获取当前显示内容对象
         */
        getVisibleObj: function () {
            return $(".page-content > div:visible");
        },
        /**
         * 添加TAB
         * @title 标题 （如果传入的title与之前不同，会修改为新的title）
         * @url TAB嵌套页面地址
         * @id DOM对象ID
         * @max TAB最大个数
         *
         * @返回 url地址
         * */
        addTab: function (title, url, id, max, parent_name) {

            if (this.checkTab(id) === false) {
                return this.activeTab(title, url, id);
            }

            var _tabs = $("li[name='topTab']");
            if (_tabs.length >= max) {
                /**
                 * 超过最大数量关闭，不做切换Tab
                 * */
                this.closeTab(_tabs[0].id, true, max);
            }

            $("li[name='topTab']").removeClass("tab-nav").addClass("tab-light");
            var html = '';
            html += '<li class="dropdown dropdown-quick-sidebar-toggler tab-nav" id="' + id + '" name="topTab">';
            html += '<a href="' + url + '"  class="tab-text" id="a_' + id + '" data-parent="' + parent_name + '">' + title + '</a>';
            html += '<a href="javascript:;" class="tab-close" id="close_' + id + '" onclick="STD.UI.closeTab(this)"><i class="fa fa-close"></i></a>';
            html += '</li>';

            $("#top_menu").append(html);

            return url;
        },

        /**
         * 激活已经存在的TAB
         * @title 标题 （如果传入的title与之前不同，会修改为新的title）
         * @url TAB嵌套页面地址
         * @id DOM对象ID
         *
         * @返回 url地址
         * */
        activeTab: function (title, url, id) {

            $("li[name='topTab']").removeClass("tab-nav").addClass("tab-light");
            $("#" + id).addClass("tab-nav").removeClass("tab-light");
            $("#a_" + id).text(title);

            return url;

        },

        /**
         * 关闭TAB
         * @id DOM对象ID
         * @no_switch == ture：不做切换TAB操作
         * @max_tab 最多TAB个数
         * 成功返回true，失败返回false（保留最后一个不能关闭）
         * */
        closeTab: function (ele, no_switch, max_tab) {

            var id = ele;
            if (typeof ele == "object") {
                id = $(ele).attr("id").split("_")[1];
            }

            var _activa_id = $(".dropdown.tab-nav").attr("id");//激活状态TAB
            var _tabs = $("li[name='topTab']");

            if (_tabs.length <= 1 && max_tab != 1) {
                return false;
            }

            //如果该页面包含详单
            var menu_id = $("#a_" + id).attr("data-menu-id");
            if (typeof menu_id != "undefined") {
                $("#" + menu_id).removeAttr("data-detail");
            }

            //移除tab和iframe
            $("#" + id).remove();
            this.closeContent(id, "id");

            if (no_switch === true) {
                return true;
            }

            var call_index = 1; //关闭之后切换TAB索引
            for (var i = 0; i < _tabs.length; i++) {
                if (_tabs[i].id == id) {
                    //如果关闭的是第一个TAB，切换到后一个，否则切换到前一个
                    call_index = i > 0 ? i : 1;
                }
            }

            if (_activa_id == id) {
                //如果关闭的是激活TAB，切换到索引TAB
                var new_id = this.switchTab(call_index, "order");
                this.switchContent($("#a_" + new_id).attr("href"))
            }

            return true;
        },


        /**
         * 切换TAB
         * @str 切换key
         * @type 切换类型 order：指定顺序  id：指定TAB
         *
         * @返回激活状态TAB ID
         * */
        switchTab: function (str, type) {

            var idx = "";
            var _tabs = $("li[name='topTab']");

            if (type == "order") {
                idx = _tabs[str - 1].id;
            } else if (type == "id") {
                idx = str;
            }

            $("li[name='topTab']").removeClass("tab-nav").addClass("tab-light");
            $("#" + idx).addClass("tab-nav").removeClass("tab-light");

            var _name = $.md5($.trim($("#a_" + idx).attr("data-parent")) + "|" + $.trim($("#a_" + idx).text()));

            this.menu_follow(_name);

            //如果当前页面在显示状态被编辑过，提示刷新
            if (Boolean($("#a_" + idx).attr("data-isModify")) == true) {
                $("#a_" + idx).removeAttr("data-isModify");
                //swal("操作提示", "当前页面被修改过，即将刷新！", "info");
                swal({
                        title: "操作提示",
                        text: "当前页面刚刚被修改过，是否刷新？",
                        confirmButtonText: "刷新",
                        cancelButtonText: "取消",
                        showCancelButton: true,
                        cancelButtonClass: "btn-danger"
                    },
                    function (isConfirm) {
                        if (isConfirm) {
                            STD.UI.refreshContent();
                        }
                    })
            }
            return idx;

        },

        /**
         * 检查TAB是否已经存在
         * @返回 不存在返回true，存在返回 false
         * */

        checkTab: function (idx) {

            var tabs = $("li[name='topTab']");
            for (var i = 0; i < tabs.length; i++) {
                if ($(tabs[i]).attr("id") == idx) {
                    return false;
                }
            }
            return true;
        },


        /**
         * 检查load页面绑定事件是否重复
         * 如有重复绑定事件，删除历史绑定事件
         */
        checkLoadEvents: function (url) {
            var _item = [];
            var _checkDel, _domEve, _domEveCk;
            if (url.indexOf("client_page_view.php?id=") > -1) {

                //检查自定义页面搜索按钮绑定事件，如有重复删除历史绑定事件
                _checkDel = function (key) {
                    for (var h = 0; h < _item.length; h++) {
                        if (key == _item[h]) {
                            //如果data附加值(page_id)重复，返回true
                            return true;
                        }
                    }
                    return false;
                };

                var _visible_id = $(".page-content > div:visible");//当前可见页面ID
                _domEve = $._data($("#index_search")[0], 'events');
                _domEveCk = _domEve.click;
                for (var i = _domEveCk.length; i > 0; i--) {
                    var page_id = _domEveCk[i - 1].data;
                    if (!_checkDel(page_id)) {
                        _item.push(page_id);
                    } else {
                        $("#index_search").unbind("click", $._data($("#index_search")[0], 'events').click[i - 1]);
                    }
                }

            } else {

                //检查固化页面document绑定事件，如有重复删除历史绑定事件
                _checkDel = function (eve, key) {
                    for (var h = 0; h < _item[eve].length; h++) {
                        if (key == _item[eve][h]) {
                            //相同事件下，如果KEY重复返回true
                            return true;
                        }
                    }
                    return false;
                };

                _domEve = $._data($(document)[0], 'events');
                for (var key in _domEve) {
                    _item[key] = [];
                }

                for (var eve in _item) {
                    _domEveCk = _domEve[eve];
                    for (var i = _domEveCk.length; i > 0; i--) {
                        var _k = _domEveCk[i - 1].selector;
                        if (typeof _k == "undefined") {
                            continue;
                        }
                        if (!_checkDel(eve, _k)) {
                            _item[eve].push(_k);
                        } else {
                            $(document).unbind(eve, $._data($(document)[0], 'events')[eve][i - 1]);
                        }
                    }
                }

            }

        },


        /*
         * 刷新当前页面加载内容
         * */

        refreshContent: function () {

            var self = this;
            var _obj = $(".page-content > div:visible");
            var _url = strdecode($.trim(_obj.attr("data-url")));


            //重置搜索条件
            var custom_page_id = $(".page-content > div:visible input[name='page_id']").val();

            if (typeof custom_page_id != "undefined") {
                common_search.removePage(custom_page_id);
            }

            var parent_name = "";
            for (var i = 0; i < leftMenu.menu_links.length; i++) {
                if (_url == leftMenu.menu_links[i].href) {
                    parent_name = leftMenu.menu_links[i].parent_name;
                    break;
                }
            }

            var page_id = leftMenu.menu_links[i].page_id;
            if (_obj.length > 0) {
                _obj.empty();
                _obj.load(_url, function () {
                    self.checkLoadEvents(_url);
                    if (_url.indexOf("nn_solidified_page") > -1 && parent_name != "") {
                        //如果是固话页面，填入面包屑上级菜单
                        var visible_id = STD.UI.getVisibleObj().attr("id");
                        var div_obj = $("#" + visible_id + " .page-breadcrumb");
                        for (var i = 0; i < div_obj.length; i++) {
                            $(div_obj[i]).prepend('<li> <span>' + parent_name + '</span> <i class="fa fa-circle"></i> </li>');
                        }
                    }
                    if (typeof page_id != "undefined" && page_id != "" && page_id.indexOf("solidification_") > -1) {
                        //页面备注
                        var ajaxStr = {};
                        ajaxStr.post_json = {
                            "condition": {
                                "id": page_id
                            }
                        };
                        ajaxStr.url = "nn_api/nn_dispatch.php?func=get_page_desc";
                        ajaxStr.success = function (result) {
                            var desc = result.desc;
                            if (typeof desc == "undefined" || desc == "") {
                                return false;
                            }
                            var visible_id = STD.UI.getVisibleObj().attr("id");
                            var small_obj = $("#" + visible_id + " h1").eq(0);
                            var small_tag = small_obj.children("small");
                            if (small_tag.length > 0) {
                                small_tag.text(desc);
                            } else {
                                $(small_obj).append('  <small>' + desc + '</small>');
                            }
                        };
                        STD.TOOL.ajax(ajaxStr);
                    }
                });
            }
        },


        /**
         * 创建新iframe
         *
         * @url 嵌入页面地址
         *
         * @返回 DOM对象ID
         * */

        addContent: function (url, obj, callback, parent_name, page_id) {
            //url = "nn_abtest/client_abtest_details.php";
            var self = this;
            var id = "iframe_" + $.md5($.trim(url));
            var newDiv = $("<div id='" + id + "' data-url='" + strencode(url) + "'></div>");
            $(".page-content > div").hide();
            newDiv.appendTo(obj);
            newDiv.load(url, function () {
                self.checkLoadEvents(url);
                if (url.indexOf("nn_solidified_page") > -1 && parent_name != "") {
                    //如果是固话页面，填入面包屑上级菜单
                    var visible_id = STD.UI.getVisibleObj().attr("id");
                    var div_obj = $("#" + visible_id + " .page-breadcrumb");
                    for (var i = 0; i < div_obj.length; i++) {
                        $(div_obj[i]).prepend('<li> <span>' + parent_name + '</span> <i class="fa fa-circle"></i> </li>');
                    }
                }
                if (typeof page_id != "undefined" && page_id != "" && page_id.indexOf("solidification_") > -1) {
                    //页面备注
                    var ajaxStr = {};
                    ajaxStr.post_json = {
                        "condition": {
                            "id": page_id
                        }
                    };
                    ajaxStr.url = "nn_api/nn_dispatch.php?func=get_page_desc";
                    ajaxStr.success = function (result) {
                        var desc = result.desc;
                        if (typeof desc == "undefined" || desc == "") {
                            return false;
                        }
                        var visible_id = STD.UI.getVisibleObj().attr("id");
                        var small_obj = $("#" + visible_id + " h1").eq(0);
                        var small_tag = small_obj.children("small");
                        if (small_tag.length > 0) {
                            small_tag.text(desc);
                        } else {
                            $(small_obj).append('  <small>' + desc + '</small>');
                        }
                    };
                    STD.TOOL.ajax(ajaxStr);
                }
                if (callback) {
                    callback();
                }
            });

            return id;
        },

        /**
         * 关闭iframe
         *
         * @str 嵌入页面地址或者DOM对象ID
         * @type 参数类型 url or id
         * */

        closeContent: function (str, type) {
            var id = "";
            if (type == "url") {
                id = "iframe_" + $.md5($.trim(str));
            } else if (type == "id") {
                id = "iframe_" + str;
            } else if (type == "href") {
                id = str;
            }
            $("#" + id).remove();
        },


        /**
         * 切换iframe内容
         * @url iframe嵌入地址
         *
         * @返回 iframe ID
         * */

        switchContent: function (url, callback) {
            var _show_id = "iframe_" + $.md5($.trim(url));
            $(".page-content > div:visible").hide();
            $("#" + _show_id).show();
            STD.eChart.reSize();

            if (callback) {
                callback();
            }

            return _show_id;
        },


        //点击顶部TAB，左边菜单跟随
        menu_follow: function (_name) {

            //如果a标签的父级属性为折叠样式，则需要激活展开
            if ($($("#left_menu a[name='" + _name + "']").get(0).parentNode.parentNode).css("display") == "none") {
                var _cn = $("a[name='" + _name + "']").get(0).parentNode.parentNode.parentNode.childNodes;
                for (var i = 0; i < _cn.length; i++) {
                    if (_cn[i].nodeName.toUpperCase() == "A") {
                        //绑定对应a标签的click事件，模拟点击展开
                        $(_cn[i]).trigger("click");
                        break;
                    }
                }
            }

            //如果为一级菜单，隐藏过期的展开效果
            if ($("#left_menu a[name='" + _name + "']").attr("data-level") == "1") {
                $(".sub-menu").each(function () {
                    if ($(this).css("display") == "block") {
                        var _cn = this.parentNode.childNodes;
                        for (var i = 0; i < _cn.length; i++) {
                            if (_cn[i].nodeName.toUpperCase() == "A") {
                                //绑定对应a标签的click事件，模拟点击折叠
                                $(_cn[i]).trigger("click");
                            }
                        }
                    }
                });
            }
            $("#left_menu a[name='" + _name + "']").trigger("click"); //模拟点击左侧菜单，实现TAB/标题跟随


        },

        /*
         * 页内切换load加载内容
         * parameter.jump_url 新加载内容路径
         * parameter.back_url 返回页面路径
         * parameter.callback 回调方法
         * 参数通过URL传递
         * */
        jumpContent: function (parameter) {

            var self = this;
            var currentOBJ = $(".page-content > div:visible");//当前显示内容对象
            currentOBJ.load(parameter.jump_url, function () {
                self.checkLoadEvents(parameter.jump_url);
            });

            if (parameter.callback) {
                parameter.callback(parameter);
            }
        },

        /*
         * 显示加载数据loading浮窗
         * 默认为当前页面
         * obj 浮窗遮罩对象
         * */
        showLoadingUI: function (obj) {

            var _mask = $(".page-content > div:visible");//当前显示内容对象
            if (typeof obj == "object") {
                _mask = obj;
            } else if (typeof obj == "string") {
                _mask = $(obj);
            }
            App.blockUI({
                //boxed: true,
                //target: $("body"),
                animate: true
            });

            setTimeout(function () {
                STD.UI.hideLoadingUI();

            }, 25 * 1000);

        },

        /*
         * 隐藏加载数据loading浮窗
         * 默认为当前页面
         * obj 浮窗遮罩对象
         * */
        hideLoadingUI: function (obj) {
            var _mask = $(".page-content > div:visible");//当前显示内容对象
            if (typeof obj == "object") {
                _mask = obj;
            } else if (typeof obj == "string") {
                _mask = $(obj);
            }
            App.unblockUI();
        },

        /*
         * UI数字累加效果激活
         * */
        counterUp: function (obj) {
            if (obj.length < 1) {
                return false;
            }
            if (!$().counterUp) {
                return;
            }
            obj.countUp({
                delay: 10,
                time: 1000
            });
        },

        /*
        切换折叠表单，用于表单内容过长的情况
        @params $form { Object } 表单的选择器或者DOM
        @params isFord { Boolean } 是否初始折叠， 默认：false
         */
        toggleForm: function ($form, isFold) {
            var CreateToggleForm = function($form, isFold) {
                var _self = this;
                _self.$form = $form;
                _self.isFold = !!isFold;
                _self.$btn = $('<a href="javascript:void(0);" class="toggle-link"></a>');
                $form.addClass('toggle-form').append(_self.$btn);
                _self.$btn.on('click', function(e){
                    e.preventDefault();
                    e.stopPropagation();
                    _self.isFold = !_self.isFold;
                    _self.toggleHeight();
                });
                _self.toggleHeight();
            };

            CreateToggleForm.prototype.toggleHeight = function(){
                var _self = this;
                _self.$btn.text(!_self.isFold ? "折叠" : "展开");
                _self.isFold ? _self.$form.addClass('fold-form') : _self.$form.removeClass('fold-form');
            };

            return new CreateToggleForm($form, isFold);
        }

    },

    /**
     * 工具函数
     * */
    TOOL: {
        /**
         * 如果窗口宽度小于980，隐藏顶部TAB标签
         * */
        SetTab: function () {
            var screen_width = window.innerWidth;

            if (screen_width < 980) {
                $(".top-menu").hide();
            } else {
                $(".top-menu").show();
            }
        },

        /**
         * iframe自适应高
         * iframe容器ID
         * */
        SetCwinHeight: function (divID, heigthType) {
            var iframeid = document.getElementById(divID);
            if (document.getElementById) {
                if (iframeid && !window.opera) {
                    var _h = 0;
                    if (iframeid.contentDocument && iframeid.contentDocument.body.offsetHeight) {
                        if (heigthType == "scroll") {
                            _h = iframeid.contentDocument.body.scrollHeight;
                        } else {// if(heigthType == "offset")
                            _h = iframeid.contentDocument.body.offsetHeight;
                        }
                    } else if (iframeid.Document && iframeid.Document.body.scrollHeight) {
                        _h = iframeid.Document.body.scrollHeight;
                    }

                    var window_height = window.innerHeight;
                    if (_h < window_height) {
                        _h = window_height;
                    }
                    if (_h < 900) {
                        //如果iframe子页面高度不足900px，强制为900px
                        _h = 900;
                    }

                    iframeid.height = _h;
                }
            }

            App.unblockUI($("#iframeMain")); //关闭iframe加载遮罩

        },

        /**
         * 前端ajax拦截创建导出任务，强制弹出重命名框
         * create_detail_export_task  为接口关键字
         * */
        checkExportTask: function(str){
            if(str.url.indexOf("create_detail_export_task") == -1 || str.isExportTask === true){
                return true;
            }
            $("#create_detail_export_task_rename").modal('show');
            $("#create_detail_export_task_rename").on('shown.bs.modal', function () {
                str.isExportTask = true;
                $("#create_detail_export_task_name").val(str.post_json.condition.name);
                $("#create_detail_export_task_rename_confirm").unbind().on("click",function(){
                    str.post_json.condition.name = $("#create_detail_export_task_name").val();
                    str.callback = function(){$("#create_detail_export_task_rename").modal('hide');};
                    STD.TOOL.getChartData(str);
                })
            });

            return false;
        },
        /**
         * 前端请求图表数据函数
         * 默认加上了平台id
         * 定时轮询
         * */
        getChartData: function (str, query_id) {

            if(STD.TOOL.checkExportTask(str) === false){
                return false;
            }

            var retry_max = 3; //最多重试次数
            var retry_interval = 3;//重试间隔（秒）
            var async = true;//同步/异步

            if (typeof str.async != "undefined") {
                async = str.async;
            }

            if (typeof str.retry_num == "undefined") {
                str.retry_num = 0;//已经重试次数
            }

            var _url = str.url;
            if (typeof query_id != "undefined") {
                _url += "&query_id=" + query_id;
            }

            var _global = str.global;
            if (_global !== false) {
                _global = true;
            }

            if (str.retry_num >= retry_max) {
                //alert('已经达到最大重试次数');
                return false;
            }

            str.retry_num++;
            // 兼容引擎部接口，不传随机数
            if(str.noRandom == true){
                _url = _url;
            }else{
                _url += "&_t=" + Math.random();
            }

            /*
             * Check post参数
             * No.1 统一加上platform_id
             * No.2 为null和undefined时转为空
             * No.3 gzgd地区码处理            *
             * No.4 导出参数处理
             * */
            var post_json = $.extend(true, {}, str.post_json);
            /*No.1*/
            if (!post_json.platform_id) {
                post_json.platform_id = localStorage.platform_id
            }

            if (post_json.condition) {
                var condition = post_json.condition;

                /*No.2*/
                for (var key in condition) {
                    if (condition[key] == null || condition[key] == "undefined") {
                        condition[key] = "";
                    }
                }

                /*No.3*/
                if (typeof condition.region_code != "undefined" && condition.region_code == "" && post_json.platform_id == "gzgd") {
                    condition.region_code = localStorage.map_code;
                }

                /*No.4*/
                if(condition.post_data && condition.post_data.condition){
                    var condition2=condition.post_data.condition;
                    for (var val in condition2) {
                        if (condition2[val] == null || condition2[val] == "undefined") {
                            condition2[val] = "";
                        }
                    }
                    if (typeof condition2.region_code != "undefined" && condition2.region_code == "" && post_json.platform_id == "gzgd") {
                        condition2.region_code = localStorage.map_code;
                    }
                }

            }

            $.ajax({
                url: _url,
                type: "post",
                dataType: "json",
                global: _global,
                data: JSON.stringify(post_json),
                cache: false,
                async: async,
                success: function (result) {

                    //强制回调，不管成功与否都会先执行此回调
                    if(str.callback){
                        str.callback();
                    }

                    if (result.ret == "0") {
                        //轮询
                        setTimeout(function () {
                            STD.TOOL.getChartData(str, result.query_id);
                        }, retry_interval * 1000);
                    }

                    if (result.ret == "1") {
                        //成功
                        str.success(result, str);
                    }

                    if (result.ret == "2" || result.ret == "14" || result.ret == "101" ||result.ret == "4") {
                        //错误
                        if (str.error) {
                            /*
                            * 修改时间：2018.12.18
                            * 将所有错误的返回处理成无数据提示
                            * */
                            if(str.nodata){
                                str.nodata(result, str);
                            }else{
                                str.error(result, str);
                            }

                        }
                    }

                    if (result.ret == "3") {
                        //无数据
                        if (str.nodata) {
                            str.nodata(result, str);
                        }
                    }

                    if (result.ret == "102") {
                        //重复
                        if (str.repeat) {
                            str.repeat(result, str);
                        }
                    }

                    if (result.ret == "4") {
                        //提示
                        if (str.overTip) {
                            str.overTip(result, str);
                        }
                    }

                    if (result.ret == "12") {
                        //不能为空
                        if (str.notempty) {
                            str.notempty(result, str);
                        }
                    }
                },
                error: function (result) {

                    //强制回调，不管成功与否都会先执行此回调
                    if(str.callback){
                        str.callback();
                    }

                    if (str.error) {
                        str.error(result, str);
                    }
                }

            });
        },

        /**
         * 前端实时请求图表数据函数
         * 默认加上了平台id
         * */
        getRealChart: function (str) {

            //平台ID
            var platform_id = localStorage.platform_id;
            if (typeof platform_id == "undefined") {
                platform_id = STD.TOOL.urlParam("platform_id");
            }
            if (str.post_json && typeof str.post_json.platform_id == "undefined") {
                str.post_json.platform_id = platform_id;
            } else if (typeof str.post_json == "undefined") {
                str.post_json = {
                    "platform_id": platform_id
                }
            }
            //地区码
            var post_json = $.extend(true, {}, str.post_json);
            if (str.post_json && str.post_json.condition && platform_id == "gzgd") {
                if (typeof str.post_json.condition.region_code != "undefined" && str.post_json.condition.region_code == "") {
                    post_json.condition.region_code = localStorage.map_code;
                }
            }

            $.ajax({
                url: str.url,
                type: "post",
                dataType: "json",
                data: JSON.stringify(post_json),
                cache: false,
                success: function (result) {

                    if (result.ret == "1") {
                        //成功
                        str.success(result);
                    }

                    if (result.ret == "2") {
                        //错误
                        if (str.error) {
                            str.error(result);
                        }
                    }

                    if (result.ret == "3") {
                        //无数据
                        if (str.nodata) {
                            str.nodata(result);
                        }
                    }

                    if (result.ret == "103") {
                        //重复
                        str.repeat(result);
                    }

                },
                error: function (result) {
                    if (str.error) {
                        str.error(result);
                    }
                }

            });
        },


        /**
         * 前端ajax常规请求
         * 与getChartData功能一样，
         * 兼容老代码，不删除该方法，直接调用getChartData
         * */
        ajax: function (str) {
            STD.TOOL.getChartData(str);
        },

        /**
         * 前端ajax常规请求
         * 不需要默认加上平台id
         * 定时轮询
         * */
        ajaxNoPlatform: function (str, query_id) {

            var retry_max = 3; //最多重试次数
            var retry_interval = 3;//重试间隔（秒）
            var async = true;//同步/异步

            if (typeof str.async != "undefined") {
                async = str.async;
            }

            if (typeof str.retry_num == "undefined") {
                str.retry_num = 0;//已经重试次数
            }

            var _url = str.url;
            if (typeof query_id != "undefined") {
                _url += "&query_id=" + query_id;
            }

            var _global = str.global;
            if (_global !== false) {
                _global = true;
            }

            if (str.retry_num >= retry_max) {
                //alert('已经达到最大重试次数');
                return false;
            }

            str.retry_num++;

            _url += "&_t=" + Math.random();

            $.ajax({
                url: _url,
                type: "post",
                dataType: "json",
                global: _global,
                data: JSON.stringify(str.post_json),
                cache: false,
                async:async,
                success: function (result) {

                    if (result.ret == "0") {
                        //轮询
                        setTimeout(function () {
                            STD.TOOL.ajax(str, result.query_id);
                        }, retry_interval * 1000);
                    } else if (result.ret == "1") {
                        str.success(result, str);
                    } else if (result.ret == "3") {
                        if (str.nodata) {
                            //如果这里需要判断状态码，可以传入回调函数
                            str.nodata(result, str);
                        }
                    } else {
                        if (str.error) {
                            //如果这里需要判断状态码，可以传入回调函数
                            str.error(result, str);
                        }
                    }
                },
                error: function (result) {
                    if (str.error) {
                        str.error(result, str);
                    }
                }
            });
        },


        /*
         * 初始化select插件
         * obj  jquery对象
         * */
        initSelectPicker: function (obj, cfg ,other_text) {
            var _aBox = true;
            if (typeof cfg != "undefined") {
                if (cfg.actionsBox === false) {
                    _aBox = false;
                }
            }
            var default_text = "";
            if (other_text !== undefined && other_text !== "") {
                default_text = other_text;
            } else {
                default_text = '请选择';
            }

            obj.selectpicker({
                noneSelectedText: default_text,
                actionsBox: _aBox,
                iconBase: 'fa',
                tickIcon: 'fa-check',
                selectAllText: '全选',
                deselectAllText: '取消',
                dropdownAlignRight: true
            });
        },

        /**
         * 循环执行回调
         * callback 回调函数集合
         * */
        loopCallback: function (callback) {
            for (var i = 0; i < callback.length; i++) {
                try {
                    if (typeof callback[i] == "function") {
                        callback[i]();
                    }
                } catch (e) {

                }

            }
        },

        /**
         * 时间/日期格式转换为星期
         * date 2018-08-08 || 2018-08-08 00:00:00
         * */
        dataToWeek: function (date) {
            var weekDay = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
            var myDate = new Date(Date.parse(date.replace(/-/g, "/")));
            return (weekDay[myDate.getDay()]) || date;
        },

        /**
         * 上周&本周
         */
        weekSpanTime: function () {
            var result = [];
            var myDate = new Date();//获取当前日期
            var weekday = myDate.getDay();//获取当前星期,返回0(周日)-6(周六)
            if (weekday == 0) {
                weekday = 7;
            }
            result[0] = this.getDataByIndex(-weekday - 6) + ',' + this.getDataByIndex(-weekday);
            result[1] = this.getDataByIndex(-weekday + 1) + ',' + this.getDataByIndex(-weekday + 7);

            return result;
        },

        /*
         * 上月&本月
         * */
        monthSpanTime: function () {
            var result = [];
            var myDate = new Date();//获取当前日期
            var year = myDate.getFullYear();
            var last_mon = myDate.getMonth();//当前月份
            var mon = last_mon + 1;//当前月份

            result[0] = (year + "/" + last_mon + "/" + "01") + "," + (year + "/" + last_mon + "/" + new Date(year, last_mon, 0).getDate());
            result[1] = (year + "/" + mon + "/" + "01") + "," + (year + "/" + mon + "/" + myDate.getDate());

            return result;
        },

        /**
         * 以当前日期为索引,指定返回间隔指定日期
         * @dayCount 正数/负数
         * @type 为 0，在日期后面自动补时
         * 正数为往后推时间（未来），负数为往前推时间（过去）
         * */
        getDataByIndex: function (dayCount, type) {
            var dt = new Date();
            dt.setDate(dt.getDate() + dayCount); //获取dayCount天后的日期
            var y = dt.getFullYear();
            var m = dt.getMonth() + 1; //获取当前月份的日期
            var d = dt.getDate();
            var result = y + "-" + m + "-" + d;
            if (type == "0") {
                result = result + " 00:00:00";
            }
            return result
        },


        /*
         * 以当前时间为起点，加或者减指定分钟
         * @timeCount  分钟数
         * @type  1:加，0:减
         * */
        changeTimeByMin: function (timeCount, type) {
            var date = new Date();

            if (type == 1) {
                date.setTime(date.getTime() + 1000 * 60 * timeCount);
            } else if (type == 0) {
                date.setTime(date.getTime() - 1000 * 60 * timeCount);
            }

            return date;
        },

        /*
         * 根据时间字符串为起点，加或者减指定分钟
         * @timeCount  分钟数
         * @type  1:加，0:减
         * */
        changeTimeByMinStr: function (dt, timeCount, type) {

            if (dt == "") {
                return "";
            }
            var date = new Date(dt);

            if (type == 1) {
                date.setTime(date.getTime() + 1000 * 60 * timeCount);
            } else if (type == 0) {
                date.setTime(date.getTime() - 1000 * 60 * timeCount);
            }
            return date;

        },

        /*
         * 将时间戳转换成日期格式
         * */
        timestampToTime: function (timestamp) {
            var date = new Date(timestamp);
            Y = date.getFullYear() + '-';
            M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
            D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate() ) + ' ';
            h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
            m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
            s = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
            return Y + M + D + h + m + s;
        },

        /*
         * 实时数据时间格式5/10整点
         * */
        getTimeByFiveMin: function (date) {
            if (typeof date == "undefined") {
                date = new Date();
            }
            var max_minute = date.getMinutes() - date.getMinutes() % 5;//取当前时间5的整倍数
            return date.Format("yyyy-M-d h:") + max_minute + ":00"
        },


        /**
         * 前端列表通过指标获取对应值
         * @_obj 数据源
         * @_id 指标名称
         * */
        getValByMetricID: function (_obj, _id) {
            for (var j = 0; j < _obj.length; j++) {
                if (_obj[j].key == _id) {
                    return _obj[j].val;
                }
            }
            return "";

        },

        //获取URL中的参数值
        urlParam: function (paramName) {
            var arrSource = [];
            var paramValue = '';
            //获取url"?"后的查询字符串
            var search_url = location.search;

            if (search_url.indexOf('?') == 0 && search_url.indexOf('=') > 1) {
                arrSource = decodeURI(search_url).substr(1).split("&");
                //遍历键值对
                for (var i = 0; i < arrSource.length; i++) {
                    if (arrSource[i].indexOf('=') > 0) {
                        if (arrSource[i].split('=')[0].toLowerCase() == paramName.toLowerCase()) {
                            paramValue = arrSource[i].split("=")[1];
                            break;
                        }
                    }
                }
            }
            return paramValue;
        },

        /*
         * json对象数组按属性排序
         * @order  asc升序  desc降序
         * @key    排序字段key
         * */
        jsonSort: function (order, key) {
            var ordAlpah = (order == 'asc') ? '>' : '<';
            var sortFun = new Function('a', 'b', 'return a.' + key + ordAlpah + 'b.' + key + '?1:-1');
            return sortFun;
        },

        /*
         * 给数字每三位增加逗号
         * */
        toThousands: function (num) {
            num = parseInt(num);
            num = (num || 0).toString();
            var result = '';
            while (num.length > 3) {
                result = ',' + num.slice(-3) + result;
                num = num.slice(0, num.length - 3);
            }
            if (num) {
                result = num + result;
            }
            return result;
        },

        /*
        * 获取表格的列数
        * @$table table的DOM对象或者slector
        * */
        getTableColumn: function($table){
            if(!$table){
                return 1;
            }

            var $list = $("thead tr", $table).eq(0).find('th'),
                columns = $list.length;

            for(var i=0,$th; $th = $list[i]; i++){
                ($($th).css('display') === 'none') && columns--;
            }

            return columns;
        },

        exportDataToCsv: function (params) {
            var params = $.extend({}, params);
            var post_json = {
                condition: {
                    "data": encodeURI(JSON.stringify(params.data || [])),
                    "file": params.file.replace(/\(\%\)/g, ''),
                    "title": encodeURI(JSON.stringify(params.title || {}))
                }
            };
            var ajaxStr = [];
            ajaxStr.url = "nn_api/nn_dispatch.php?func=create_csv";
            ajaxStr.post_json = post_json;
            ajaxStr.success = function (result) {
                var before = location.href.split("/web/")[0] + "/web";
                window.location.href = before + result.data.url;
            }

            STD.TOOL.getChartData(ajaxStr);
        }
    },

    /**
     * echart里面用到的数据格式转换，初始化对象
     * */
    eChart: {

        /**
         * 当前页面加载的所有图表对象都会push到这里
         * */
        objs: [],

        /**
         * 格式化echart数据格式
         * @json ajax返回json数据
         * @datatype  图表数据类型
         * @callback  回调函数
         *
         * @返回数组对象
         * @result.spot数组 X坐标点
         * @result.data数组 Y坐标点
         * @result.desc数组 指标名称
         * */
        formatData: function (json, datatype, callback) {

            if(json.data == null){
                return [];
            }

            var result = [];
            var source = json.data;
            var spot = [];
            var data = [];
            var desc = [];
            var metric = [];
            var metric_unit = ""; //单位
            var std_paramter = "";//数据请求参数

            if (typeof json.std_paramter != "undefined") {
                std_paramter = json.std_paramter;
            }

            //遍历desc
            var _desc = json.desc;
            for (var key in _desc) {
                //遍历指标KEY和描述
                if (key == "metric_unit") {
                    metric_unit = _desc[key];
                    continue;
                }
                metric.push(key);
            }
            metric.sort();
            //指标翻译
            for (var n = 0; n < metric.length; n++) {
                desc.push(_desc[metric[n]]);
            }
            //每个指标创建一个数组对象
            for (var h = 0; h < metric.length; h++) {
                if (typeof(data[h]) == "undefined") {
                    data[h] = [];
                }
            }
            //遍历data
            for (var i = 0; i < source.length; i++) {
                spot.push(source[i].lat_name);
                var _item = source[i].data_list;
                if (typeof(_item) == "undefined") {
                    continue;
                }
                //data_list为空时补全数组
                if (_item == "") {
                    for (var k = 0; k < metric.length; k++) {
                        data[k].push("");
                    }
                    continue;
                }
                //data_list不为空
                for (var m = 0; m < metric.length; m++) {
                    var list_key = [];
                    for (var j = 0; j < _item.length; j++) {
                        list_key.push(_item[j].key);
                        if (metric[m] == _item[j].key) {
                            //根据指标key匹配对应val，把相同指标数据放入同一个数组
                            if (datatype == "pie" || datatype == "pieR" || datatype == "rose") {
                                //如果图表类型为饼状图或者圆环图，value不能非数字
                                //由于强制为0会导致无法画出半圆，所以回退修改 2017.5.23
                                data[m].push(isNaN(parseInt(_item[j].val)) ? 0 : _item[j].val);
                            } else {
                                data[m].push(isNaN(parseInt(_item[j].val)) ? '-' : _item[j].val);
                            }
                            break;
                        }
                    }
                    //data_list没有metric
                    if ($.inArray(metric[m], list_key) < 0) {
                        data[m].push("");
                    }
                }
            }

            result.spot = spot;
            result.data = data;
            result.desc = desc;
            result.metric_unit = metric_unit;
            result.std_paramter = std_paramter;

            if (typeof callback === "function") {
                result = callback(result);
            }

            return result;

        },

        /**
         * 初始化图表控件，增加loading动画
         * @string 控件容器ID 或者 eCharts对象
         * @isLoading 是否现在加载提示
         * */

        init: function (string, isLoading) {

            var demo = null;
            this.clear(string);
            var theme = "{\n    \"color\": [\n        \"#516b91\",\n        \"#59c4e6\",\n        \"#edafda\",\n        \"#93b7e3\",\n        \"#a5e7f0\",\n        \"#cbb0e3\"\n    ],\n    \"backgroundColor\": \"rgba(0,0,0,0)\",\n    \"textStyle\": {},\n    \"title\": {\n        \"textStyle\": {\n            \"color\": \"#516b91\"\n        },\n        \"subtextStyle\": {\n            \"color\": \"#93b7e3\"\n        }\n    },\n    \"line\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"borderWidth\": \"2\"\n            }\n        },\n        \"lineStyle\": {\n            \"normal\": {\n                \"width\": \"2\"\n            }\n        },\n        \"symbolSize\": \"6\",\n        \"symbol\": \"emptyCircle\",\n        \"smooth\": true\n    },\n    \"radar\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"borderWidth\": \"2\"\n            }\n        },\n        \"lineStyle\": {\n            \"normal\": {\n                \"width\": \"2\"\n            }\n        },\n        \"symbolSize\": \"6\",\n        \"symbol\": \"emptyCircle\",\n        \"smooth\": true\n    },\n    \"bar\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"barBorderWidth\": 0,\n                \"barBorderColor\": \"#ccc\"\n            },\n            \"emphasis\": {\n                \"barBorderWidth\": 0,\n                \"barBorderColor\": \"#ccc\"\n            }\n        }\n    },\n    \"pie\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            },\n            \"emphasis\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            }\n        }\n    },\n    \"scatter\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            },\n            \"emphasis\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            }\n        }\n    },\n    \"boxplot\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            },\n            \"emphasis\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            }\n        }\n    },\n    \"parallel\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            },\n            \"emphasis\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            }\n        }\n    },\n    \"sankey\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            },\n            \"emphasis\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            }\n        }\n    },\n    \"funnel\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            },\n            \"emphasis\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            }\n        }\n    },\n    \"gauge\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            },\n            \"emphasis\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            }\n        }\n    },\n    \"candlestick\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"color\": \"#edafda\",\n                \"color0\": \"transparent\",\n                \"borderColor\": \"#d680bc\",\n                \"borderColor0\": \"#8fd3e8\",\n                \"borderWidth\": \"2\"\n            }\n        }\n    },\n    \"graph\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            }\n        },\n        \"lineStyle\": {\n            \"normal\": {\n                \"width\": 1,\n                \"color\": \"#aaa\"\n            }\n        },\n        \"symbolSize\": \"6\",\n        \"symbol\": \"emptyCircle\",\n        \"smooth\": true,\n        \"color\": [\n            \"#516b91\",\n            \"#59c4e6\",\n            \"#edafda\",\n            \"#93b7e3\",\n            \"#a5e7f0\",\n            \"#cbb0e3\"\n        ],\n        \"label\": {\n            \"normal\": {\n                \"textStyle\": {\n                    \"color\": \"#eee\"\n                }\n            }\n        }\n    },\n    \"map\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"areaColor\": \"#f3f3f3\",\n                \"borderColor\": \"#516b91\",\n                \"borderWidth\": 0.5\n            },\n            \"emphasis\": {\n                \"areaColor\": \"rgba(165,231,240,1)\",\n                \"borderColor\": \"#516b91\",\n                \"borderWidth\": 1\n            }\n        },\n        \"label\": {\n            \"normal\": {\n                \"textStyle\": {\n                    \"color\": \"#000\"\n                }\n            },\n            \"emphasis\": {\n                \"textStyle\": {\n                    \"color\": \"rgb(81,107,145)\"\n                }\n            }\n        }\n    },\n    \"geo\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"areaColor\": \"#f3f3f3\",\n                \"borderColor\": \"#516b91\",\n                \"borderWidth\": 0.5\n            },\n            \"emphasis\": {\n                \"areaColor\": \"rgba(165,231,240,1)\",\n                \"borderColor\": \"#516b91\",\n                \"borderWidth\": 1\n            }\n        },\n        \"label\": {\n            \"normal\": {\n                \"textStyle\": {\n                    \"color\": \"#000\"\n                }\n            },\n            \"emphasis\": {\n                \"textStyle\": {\n                    \"color\": \"rgb(81,107,145)\"\n                }\n            }\n        }\n    },\n    \"categoryAxis\": {\n        \"axisLine\": {\n            \"show\": true,\n            \"lineStyle\": {\n                \"color\": \"#cccccc\"\n            }\n        },\n        \"axisTick\": {\n            \"show\": false,\n            \"lineStyle\": {\n                \"color\": \"#333\"\n            }\n        },\n        \"axisLabel\": {\n            \"show\": true,\n            \"textStyle\": {\n                \"color\": \"#999999\"\n            }\n        },\n        \"splitLine\": {\n            \"show\": true,\n            \"lineStyle\": {\n                \"color\": [\n                    \"#eeeeee\"\n                ]\n            }\n        },\n        \"splitArea\": {\n            \"show\": false,\n            \"areaStyle\": {\n                \"color\": [\n                    \"rgba(250,250,250,0.05)\",\n                    \"rgba(200,200,200,0.02)\"\n                ]\n            }\n        }\n    },\n    \"valueAxis\": {\n        \"axisLine\": {\n            \"show\": true,\n            \"lineStyle\": {\n                \"color\": \"#cccccc\"\n            }\n        },\n        \"axisTick\": {\n            \"show\": false,\n            \"lineStyle\": {\n                \"color\": \"#333\"\n            }\n        },\n        \"axisLabel\": {\n            \"show\": true,\n            \"textStyle\": {\n                \"color\": \"#999999\"\n            }\n        },\n        \"splitLine\": {\n            \"show\": true,\n            \"lineStyle\": {\n                \"color\": [\n                    \"#eeeeee\"\n                ]\n            }\n        },\n        \"splitArea\": {\n            \"show\": false,\n            \"areaStyle\": {\n                \"color\": [\n                    \"rgba(250,250,250,0.05)\",\n                    \"rgba(200,200,200,0.02)\"\n                ]\n            }\n        }\n    },\n    \"logAxis\": {\n        \"axisLine\": {\n            \"show\": true,\n            \"lineStyle\": {\n                \"color\": \"#cccccc\"\n            }\n        },\n        \"axisTick\": {\n            \"show\": false,\n            \"lineStyle\": {\n                \"color\": \"#333\"\n            }\n        },\n        \"axisLabel\": {\n            \"show\": true,\n            \"textStyle\": {\n                \"color\": \"#999999\"\n            }\n        },\n        \"splitLine\": {\n            \"show\": true,\n            \"lineStyle\": {\n                \"color\": [\n                    \"#eeeeee\"\n                ]\n            }\n        },\n        \"splitArea\": {\n            \"show\": false,\n            \"areaStyle\": {\n                \"color\": [\n                    \"rgba(250,250,250,0.05)\",\n                    \"rgba(200,200,200,0.02)\"\n                ]\n            }\n        }\n    },\n    \"timeAxis\": {\n        \"axisLine\": {\n            \"show\": true,\n            \"lineStyle\": {\n                \"color\": \"#cccccc\"\n            }\n        },\n        \"axisTick\": {\n            \"show\": false,\n            \"lineStyle\": {\n                \"color\": \"#333\"\n            }\n        },\n        \"axisLabel\": {\n            \"show\": true,\n            \"textStyle\": {\n                \"color\": \"#999999\"\n            }\n        },\n        \"splitLine\": {\n            \"show\": true,\n            \"lineStyle\": {\n                \"color\": [\n                    \"#eeeeee\"\n                ]\n            }\n        },\n        \"splitArea\": {\n            \"show\": false,\n            \"areaStyle\": {\n                \"color\": [\n                    \"rgba(250,250,250,0.05)\",\n                    \"rgba(200,200,200,0.02)\"\n                ]\n            }\n        }\n    },\n    \"toolbox\": {\n        \"iconStyle\": {\n            \"normal\": {\n                \"borderColor\": \"#999\"\n            },\n            \"emphasis\": {\n                \"borderColor\": \"#666\"\n            }\n        }\n    },\n    \"legend\": {\n        \"textStyle\": {\n            \"color\": \"#999999\"\n        }\n    },\n    \"tooltip\": {\n        \"axisPointer\": {\n            \"lineStyle\": {\n                \"color\": \"#ccc\",\n                \"width\": 1\n            },\n            \"crossStyle\": {\n                \"color\": \"#ccc\",\n                \"width\": 1\n            }\n        }\n    },\n    \"timeline\": {\n        \"lineStyle\": {\n            \"color\": \"#8fd3e8\",\n            \"width\": 1\n        },\n        \"itemStyle\": {\n            \"normal\": {\n                \"color\": \"#8fd3e8\",\n                \"borderWidth\": 1\n            },\n            \"emphasis\": {\n                \"color\": \"#8fd3e8\"\n            }\n        },\n        \"controlStyle\": {\n            \"normal\": {\n                \"color\": \"#8fd3e8\",\n                \"borderColor\": \"#8fd3e8\",\n                \"borderWidth\": 0.5\n            },\n            \"emphasis\": {\n                \"color\": \"#8fd3e8\",\n                \"borderColor\": \"#8fd3e8\",\n                \"borderWidth\": 0.5\n            }\n        },\n        \"checkpointStyle\": {\n            \"color\": \"#8fd3e8\",\n            \"borderColor\": \"rgba(138,124,168,0.37)\"\n        },\n        \"label\": {\n            \"normal\": {\n                \"textStyle\": {\n                    \"color\": \"#8fd3e8\"\n                }\n            },\n            \"emphasis\": {\n                \"textStyle\": {\n                    \"color\": \"#8fd3e8\"\n                }\n            }\n        }\n    },\n    \"visualMap\": {\n        \"color\": [\n            \"#516b91\",\n            \"#59c4e6\",\n            \"#a5e7f0\"\n        ]\n    },\n    \"dataZoom\": {\n        \"backgroundColor\": \"rgba(0,0,0,0)\",\n        \"dataBackgroundColor\": \"rgba(255,255,255,0.3)\",\n        \"fillerColor\": \"rgba(167,183,204,0.4)\",\n        \"handleColor\": \"#a7b7cc\",\n        \"handleSize\": \"100%\",\n        \"textStyle\": {\n            \"color\": \"#333\"\n        }\n    },\n    \"markPoint\": {\n        \"label\": {\n            \"normal\": {\n                \"textStyle\": {\n                    \"color\": \"#eee\"\n                }\n            },\n            \"emphasis\": {\n                \"textStyle\": {\n                    \"color\": \"#eee\"\n                }\n            }\n        }\n    }\n}";
            if ("object" != typeof theme) {
                theme = JSON.parse(theme);
            }
            echarts.registerTheme('westeros', theme)
            demo = echarts.init(document.getElementById(string), 'westeros');
            this.objs.push(demo);
            if (isLoading !== false) {
                demo.showLoading();
            }
            return demo;
        },

        /**
         * 刷新图表控件数据，不重新渲染整个图表
         * @string 控件容器ID 或者 eCharts对象
         * @isLoading 是否现在加载提示
         * */
        refresh: function (string, isLoading) {

            var demo = null;
            if (typeof(echarts.getInstanceByDom(document.getElementById(string))) != "object") {
                var theme = "{\n    \"color\": [\n        \"#516b91\",\n        \"#59c4e6\",\n        \"#edafda\",\n        \"#93b7e3\",\n        \"#a5e7f0\",\n        \"#cbb0e3\"\n    ],\n    \"backgroundColor\": \"rgba(0,0,0,0)\",\n    \"textStyle\": {},\n    \"title\": {\n        \"textStyle\": {\n            \"color\": \"#516b91\"\n        },\n        \"subtextStyle\": {\n            \"color\": \"#93b7e3\"\n        }\n    },\n    \"line\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"borderWidth\": \"2\"\n            }\n        },\n        \"lineStyle\": {\n            \"normal\": {\n                \"width\": \"2\"\n            }\n        },\n        \"symbolSize\": \"6\",\n        \"symbol\": \"emptyCircle\",\n        \"smooth\": true\n    },\n    \"radar\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"borderWidth\": \"2\"\n            }\n        },\n        \"lineStyle\": {\n            \"normal\": {\n                \"width\": \"2\"\n            }\n        },\n        \"symbolSize\": \"6\",\n        \"symbol\": \"emptyCircle\",\n        \"smooth\": true\n    },\n    \"bar\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"barBorderWidth\": 0,\n                \"barBorderColor\": \"#ccc\"\n            },\n            \"emphasis\": {\n                \"barBorderWidth\": 0,\n                \"barBorderColor\": \"#ccc\"\n            }\n        }\n    },\n    \"pie\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            },\n            \"emphasis\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            }\n        }\n    },\n    \"scatter\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            },\n            \"emphasis\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            }\n        }\n    },\n    \"boxplot\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            },\n            \"emphasis\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            }\n        }\n    },\n    \"parallel\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            },\n            \"emphasis\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            }\n        }\n    },\n    \"sankey\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            },\n            \"emphasis\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            }\n        }\n    },\n    \"funnel\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            },\n            \"emphasis\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            }\n        }\n    },\n    \"gauge\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            },\n            \"emphasis\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            }\n        }\n    },\n    \"candlestick\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"color\": \"#edafda\",\n                \"color0\": \"transparent\",\n                \"borderColor\": \"#d680bc\",\n                \"borderColor0\": \"#8fd3e8\",\n                \"borderWidth\": \"2\"\n            }\n        }\n    },\n    \"graph\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"borderWidth\": 0,\n                \"borderColor\": \"#ccc\"\n            }\n        },\n        \"lineStyle\": {\n            \"normal\": {\n                \"width\": 1,\n                \"color\": \"#aaa\"\n            }\n        },\n        \"symbolSize\": \"6\",\n        \"symbol\": \"emptyCircle\",\n        \"smooth\": true,\n        \"color\": [\n            \"#516b91\",\n            \"#59c4e6\",\n            \"#edafda\",\n            \"#93b7e3\",\n            \"#a5e7f0\",\n            \"#cbb0e3\"\n        ],\n        \"label\": {\n            \"normal\": {\n                \"textStyle\": {\n                    \"color\": \"#eee\"\n                }\n            }\n        }\n    },\n    \"map\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"areaColor\": \"#f3f3f3\",\n                \"borderColor\": \"#516b91\",\n                \"borderWidth\": 0.5\n            },\n            \"emphasis\": {\n                \"areaColor\": \"rgba(165,231,240,1)\",\n                \"borderColor\": \"#516b91\",\n                \"borderWidth\": 1\n            }\n        },\n        \"label\": {\n            \"normal\": {\n                \"textStyle\": {\n                    \"color\": \"#000\"\n                }\n            },\n            \"emphasis\": {\n                \"textStyle\": {\n                    \"color\": \"rgb(81,107,145)\"\n                }\n            }\n        }\n    },\n    \"geo\": {\n        \"itemStyle\": {\n            \"normal\": {\n                \"areaColor\": \"#f3f3f3\",\n                \"borderColor\": \"#516b91\",\n                \"borderWidth\": 0.5\n            },\n            \"emphasis\": {\n                \"areaColor\": \"rgba(165,231,240,1)\",\n                \"borderColor\": \"#516b91\",\n                \"borderWidth\": 1\n            }\n        },\n        \"label\": {\n            \"normal\": {\n                \"textStyle\": {\n                    \"color\": \"#000\"\n                }\n            },\n            \"emphasis\": {\n                \"textStyle\": {\n                    \"color\": \"rgb(81,107,145)\"\n                }\n            }\n        }\n    },\n    \"categoryAxis\": {\n        \"axisLine\": {\n            \"show\": true,\n            \"lineStyle\": {\n                \"color\": \"#cccccc\"\n            }\n        },\n        \"axisTick\": {\n            \"show\": false,\n            \"lineStyle\": {\n                \"color\": \"#333\"\n            }\n        },\n        \"axisLabel\": {\n            \"show\": true,\n            \"textStyle\": {\n                \"color\": \"#999999\"\n            }\n        },\n        \"splitLine\": {\n            \"show\": true,\n            \"lineStyle\": {\n                \"color\": [\n                    \"#eeeeee\"\n                ]\n            }\n        },\n        \"splitArea\": {\n            \"show\": false,\n            \"areaStyle\": {\n                \"color\": [\n                    \"rgba(250,250,250,0.05)\",\n                    \"rgba(200,200,200,0.02)\"\n                ]\n            }\n        }\n    },\n    \"valueAxis\": {\n        \"axisLine\": {\n            \"show\": true,\n            \"lineStyle\": {\n                \"color\": \"#cccccc\"\n            }\n        },\n        \"axisTick\": {\n            \"show\": false,\n            \"lineStyle\": {\n                \"color\": \"#333\"\n            }\n        },\n        \"axisLabel\": {\n            \"show\": true,\n            \"textStyle\": {\n                \"color\": \"#999999\"\n            }\n        },\n        \"splitLine\": {\n            \"show\": true,\n            \"lineStyle\": {\n                \"color\": [\n                    \"#eeeeee\"\n                ]\n            }\n        },\n        \"splitArea\": {\n            \"show\": false,\n            \"areaStyle\": {\n                \"color\": [\n                    \"rgba(250,250,250,0.05)\",\n                    \"rgba(200,200,200,0.02)\"\n                ]\n            }\n        }\n    },\n    \"logAxis\": {\n        \"axisLine\": {\n            \"show\": true,\n            \"lineStyle\": {\n                \"color\": \"#cccccc\"\n            }\n        },\n        \"axisTick\": {\n            \"show\": false,\n            \"lineStyle\": {\n                \"color\": \"#333\"\n            }\n        },\n        \"axisLabel\": {\n            \"show\": true,\n            \"textStyle\": {\n                \"color\": \"#999999\"\n            }\n        },\n        \"splitLine\": {\n            \"show\": true,\n            \"lineStyle\": {\n                \"color\": [\n                    \"#eeeeee\"\n                ]\n            }\n        },\n        \"splitArea\": {\n            \"show\": false,\n            \"areaStyle\": {\n                \"color\": [\n                    \"rgba(250,250,250,0.05)\",\n                    \"rgba(200,200,200,0.02)\"\n                ]\n            }\n        }\n    },\n    \"timeAxis\": {\n        \"axisLine\": {\n            \"show\": true,\n            \"lineStyle\": {\n                \"color\": \"#cccccc\"\n            }\n        },\n        \"axisTick\": {\n            \"show\": false,\n            \"lineStyle\": {\n                \"color\": \"#333\"\n            }\n        },\n        \"axisLabel\": {\n            \"show\": true,\n            \"textStyle\": {\n                \"color\": \"#999999\"\n            }\n        },\n        \"splitLine\": {\n            \"show\": true,\n            \"lineStyle\": {\n                \"color\": [\n                    \"#eeeeee\"\n                ]\n            }\n        },\n        \"splitArea\": {\n            \"show\": false,\n            \"areaStyle\": {\n                \"color\": [\n                    \"rgba(250,250,250,0.05)\",\n                    \"rgba(200,200,200,0.02)\"\n                ]\n            }\n        }\n    },\n    \"toolbox\": {\n        \"iconStyle\": {\n            \"normal\": {\n                \"borderColor\": \"#999\"\n            },\n            \"emphasis\": {\n                \"borderColor\": \"#666\"\n            }\n        }\n    },\n    \"legend\": {\n        \"textStyle\": {\n            \"color\": \"#999999\"\n        }\n    },\n    \"tooltip\": {\n        \"axisPointer\": {\n            \"lineStyle\": {\n                \"color\": \"#ccc\",\n                \"width\": 1\n            },\n            \"crossStyle\": {\n                \"color\": \"#ccc\",\n                \"width\": 1\n            }\n        }\n    },\n    \"timeline\": {\n        \"lineStyle\": {\n            \"color\": \"#8fd3e8\",\n            \"width\": 1\n        },\n        \"itemStyle\": {\n            \"normal\": {\n                \"color\": \"#8fd3e8\",\n                \"borderWidth\": 1\n            },\n            \"emphasis\": {\n                \"color\": \"#8fd3e8\"\n            }\n        },\n        \"controlStyle\": {\n            \"normal\": {\n                \"color\": \"#8fd3e8\",\n                \"borderColor\": \"#8fd3e8\",\n                \"borderWidth\": 0.5\n            },\n            \"emphasis\": {\n                \"color\": \"#8fd3e8\",\n                \"borderColor\": \"#8fd3e8\",\n                \"borderWidth\": 0.5\n            }\n        },\n        \"checkpointStyle\": {\n            \"color\": \"#8fd3e8\",\n            \"borderColor\": \"rgba(138,124,168,0.37)\"\n        },\n        \"label\": {\n            \"normal\": {\n                \"textStyle\": {\n                    \"color\": \"#8fd3e8\"\n                }\n            },\n            \"emphasis\": {\n                \"textStyle\": {\n                    \"color\": \"#8fd3e8\"\n                }\n            }\n        }\n    },\n    \"visualMap\": {\n        \"color\": [\n            \"#516b91\",\n            \"#59c4e6\",\n            \"#a5e7f0\"\n        ]\n    },\n    \"dataZoom\": {\n        \"backgroundColor\": \"rgba(0,0,0,0)\",\n        \"dataBackgroundColor\": \"rgba(255,255,255,0.3)\",\n        \"fillerColor\": \"rgba(167,183,204,0.4)\",\n        \"handleColor\": \"#a7b7cc\",\n        \"handleSize\": \"100%\",\n        \"textStyle\": {\n            \"color\": \"#333\"\n        }\n    },\n    \"markPoint\": {\n        \"label\": {\n            \"normal\": {\n                \"textStyle\": {\n                    \"color\": \"#eee\"\n                }\n            },\n            \"emphasis\": {\n                \"textStyle\": {\n                    \"color\": \"#eee\"\n                }\n            }\n        }\n    }\n}";
                if ("object" == typeof theme) {
                    theme = JSON.stringify(theme.theme);
                }
                theme = JSON.parse(theme);
                echarts.registerTheme('westeros', theme)
                demo = echarts.init(document.getElementById(string), 'westeros');
                this.objs.push(demo);
            } else {
                demo = echarts.getInstanceByDom(document.getElementById(string));
            }
            if (isLoading !== false) {
                demo.showLoading();
            }
            return demo;
        },

        /*
         * 清空/销毁 echart对象
         * @string 控件容器ID
         * */
        clear: function (string) {
            var demo = null;
            if (echarts.getInstanceByDom && typeof(echarts.getInstanceByDom(document.getElementById(string))) == "object") {
                demo = echarts.getInstanceByDom(document.getElementById(string));
                var _obj = this.objs;
                for (var i = 0; i < _obj.length; i++) {
                    if (_obj[i] == demo) {
                        this.objs.splice(i, 1);
                        demo.clear();
                        demo.dispose();
                    }
                }
            }
        },

        /**
         * 开始渲染echart图表，统一控制loading页面的消失/样式
         * @obj echart对象
         * @option 图表数据核心
         * */
        show: function (demo, option, callback) {
            //获取名称
            if (typeof option.stdExtend != "undefined") {
                $(demo._dom).attr("data-stdext", JSON.stringify(option.stdExtend))
            }
            var chart_parent = $(demo._dom).parent(".portlet-body");
            var chart_sibling = chart_parent.prev(".portlet-title");
            var title = "";
            if (typeof chart_sibling != "undefined") {
                title = chart_sibling.find(".caption > .caption-subject").text();
            }
            //设置title为图表名称,保存为图片时使用
            if (typeof option.title == "undefined") {
                option.title = {
                    text: "",
                    show: false
                };
            }
            option.title.text = title;

            demo.setOption(option);
            demo.hideLoading();

            if (typeof callback === "function") {
                callback(demo);
            }

            return demo;
        },

        /**
         * eCharts对象自适应浏览器大小
         * */
        reSize: function () {
            //console.log("resize");
            var objs = this.objs;
            for (var i = objs.length; i > 0; i--) {

                var idx = i - 1;
                if (!$("div[_echarts_instance_='" + objs[idx].id + "']").length || typeof(objs[idx]) == "undefined") {
                    //销毁不存在的echarts对象
                    objs.splice(idx, 1);
                    continue;
                }

                if ($("body").find(".page-content").length > 0 && !$(".page-content > div:visible div[_echarts_instance_='" + objs[idx].id + "']").length) {
                    //忽略非当前可见页面ehcarts对象,减少渲染次数,防止浏览器卡死
                    continue;
                }
                objs[idx].resize();
            }
        },

        /**
         * echart数据加载失败，统一样式
         * @obj  容器jQuery对象
         * @img  图片路径
         * @cls  样式表
         * */
        showError: function (obj, img, cls) {
            if (typeof img == "undefined") {
                img = '数据加载失败';
            }

            if (typeof cls == "undefined") {
                cls = 'loading_error_img';
            }

            obj.html('<div class="' + cls + '" unselectable="on" onselectstart="return false;"><span class="loading_font">' + img + '</span></div>');
        },

        /**
         * echart无数据，统一样式
         * @obj  容器jQuery对象
         * @img  图片路径
         * @cls  样式表
         * */
        noData: function (obj, img, cls) {
            if (typeof img == "undefined") {
                img = '暂无数据';
            }

            if (typeof cls == "undefined") {
                cls = 'loading_error_img';
            }

            obj.html('<div class="' + cls + '" unselectable="on" onselectstart="return false;"><span class="loading_font">' + img + '</span></div>');
        }

    },

    toolTip: {
        //指标算法提示信息
        Set: function (selector, pos_my, pos_at) {

            if (typeof selector === "undefined") {
                selector = '.help';
            }
            if (typeof pos_my === "undefined") {
                pos_my = 'left+10 top-21';
            }
            if (typeof pos_at === "undefined") {
                pos_at = 'right center';
            }
            $('body').on('mouseenter', selector, function (e) {
                var self = $(this);
                var tip = $('#' + $(this).attr('action-frame'));
                tip.stop().fadeIn();

                tip.position({
                    my: pos_my,
                    at: pos_at,
                    of: $(this),
                    collision: 'flip',//翻转元素
                    using: function (pos, feedback) {
                        $('#' + $(self).attr('action-frame')).css(pos);
                        //翻转元素的同时，翻转三角形
                        if (feedback.horizontal === 'right') {
                            feedback.element.element.find('.corner_right').addClass('corner_left');
                            feedback.element.element.find('.corner_over').removeClass('corner_over_right');
                        } else if (feedback.horizontal === 'left') {
                            feedback.element.element.find('.corner_right').removeClass('corner_left');
                            feedback.element.element.find('.corner_over').addClass('corner_over_right');
                        }
                    }
                });
            });
            $('body').on('mouseleave', selector, function (e) {
                var tip = $('#' + $(this).attr('action-frame'));
                tip.stop().fadeOut();
            });
        },
        //数据量超过百万，统一"万"单位，超过百亿，统一"亿"单位
        showNum: function (num) {
            return num;
            //var million = 1;
            //var billion = 1000000000;
            //var num_str = num;
            //if (million <= Math.abs(num) && Math.abs(num) < billion) {
            //    num_str = (num / million).toFixed(2).toString() + '百万';
            //}
            //if (num >= billion) {
            //    num_str = (num / billion).toFixed(2).toString() + '十亿';
            //}
            //return num_str;
        }
    },

    /*
     * sweetalert模拟弹窗
     * */
    sweetAlert: {

        /*
         * 删除确认
         * */
        delConfirm: function (backcall, _str) {
            swal({
                title: "您确定要删除吗?",
                text: "删除数据不可恢复",
                type: "warning",
                html: true,
                showCancelButton: true,
                closeOnConfirm: false,
                showLoaderOnConfirm: true,
                confirmButtonText: "是的，我要删除",
                cancelButtonText: "取消删除",
                confirmButtonColor: "#ec6c62",
                confirmButtonClass: "btn-danger",
                cancelButtonClass: "btn-default"
            }, function (isConfirm) {
                if (isConfirm && backcall) {
                    backcall(isConfirm, _str);
                }
            });
        }

    }

};






/**
 * 对Date的扩展，将 Date 转化为指定格式的String
 * 月(M)、日(d)、12小时(h)、24小时(H)、分(m)、秒(s)、周(E)、季度(q) 可以用 1-2 个占位符
 * 年(y)可以用 1-4 个占位符，毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
 * eg:
 * (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
 * (new Date()).Format("yyyy-MM-dd E HH:mm:ss") ==> 2009-03-10 二 20:09:04
 * (new Date()).Format("yyyy-MM-dd EE hh:mm:ss") ==> 2009-03-10 周二 08:09:04
 * (new Date()).Format("yyyy-MM-dd EEE hh:mm:ss") ==> 2009-03-10 星期二 08:09:04
 * (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
 */
Date.prototype.Format = function (fmt, count) {
    var o = {
        "M+": this.getMonth() + 1, //月份
        "d+": this.getDate(), //日
        "h+": this.getHours(), //小时
        "m+": this.getMinutes(), //分
        "s+": this.getSeconds(), //秒
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
        "S": this.getMilliseconds() //毫秒
    };
    if (/(y+)/.test(fmt)) {
        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    }
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt))
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
};

/*
 * 比较两个时间相差
 * document.writeln("秒差: "+starTime .dateDiff("s",endTime )+"<br>");
 * document.writeln("分差: "+starTime .dateDiff("n",endTime )+"<br>");
 * document.writeln("時差: "+starTime .dateDiff("h",endTime )+"<br>");
 * document.writeln("日差: "+starTime .dateDiff("d",endTime )+"<br>");
 * document.writeln("週差: "+starTime .dateDiff("w",endTime )+"<br>");
 * document.writeln("月差: "+starTime .dateDiff("m",endTime )+"<br>");
 * document.writeln("年差: "+starTime .dateDiff("y",endTime )+"<br>");
 * */
Date.prototype.dateDiff = function (interval, endTime) {
    switch (interval) {
        //計算秒差
        case "s":
            return parseInt((endTime - this) / 1000);

        //計算分差
        case "n":
            return parseInt((endTime - this) / 60000);

        //計算時差
        case "h":
            return parseInt((endTime - this) / 3600000);

        //計算日差
        case "d":
            return parseInt((endTime - this) / 86400000);

        //計算週差
        case "w":
            return parseInt((endTime - this) / (86400000 * 7));

        //計算月差
        case "m":
            return (endTime.getMonth() + 1) + ((endTime.getFullYear() - this.getFullYear()) * 12) - (this.getMonth() + 1);

        //計算年差
        case "y":
            return endTime.getFullYear() - this.getFullYear();

        //輸入有誤
        default:
            return undefined;
    }
}

//批量替换字符串
String.prototype.replaceAll = function (s1, s2) {
    return this.replace(new RegExp(s1, "gm"), s2);
}

//计算字符串长度(英文占1个字符，中文汉字占2个字符)
String.prototype.gblen = function () {
    var len = 0;
    for (var i = 0; i < this.length; i++) {
        if (this.charCodeAt(i) > 127 || this.charCodeAt(i) == 94) {
            len += 2;
        } else {
            len++;
        }
    }
    return len;
}
